SpringBoot啓動報錯:[restartedMain] o.s.boot.SpringApplication : Application run failed

在基于Spring Boot 2.5.1的Maven多模块项目中,启动时遇到错误。错误通常源于代码或配置问题。从错误信息中,发现是解析xxxMapper.xml时,com.xxx.xxx.Article找不到。经检查,发现在resultType的目录配置有误,修正后问题得到解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource

項目是用Maven搭建的基於spring boot2.5.1的多模塊項目.啓動就發生了錯誤.

以我學習別人的經驗,計算機只是按照它自己特定的方式執行程式.出錯通常是我們自己哪裏出了錯誤,出錯了不要怕正是我們進步的時候,記錄一下錯誤消息,以避免下次出現同樣的錯,又不知道怎麽辦,只能又在網際網絡上找自己想要的答案,可以先自己試著在錯誤信息裏,從上至下找下大概的問題,也許是哪裏代碼錯了,或者資料路徑錯了,總之自己應該在沒有別人的情況下,自己先試著解決問題.

錯誤的部分信息:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.1)

INFO 18476 --- [  restartedMain] t.g.xxx.xxx.UserApplication           : The following profiles are active: config
INFO 18476 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
INFO 18476 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
WARN 18476 --- [  restartedMain] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[xxx.xxx.user.mapper.*]' package. Please check your configuration.
INFO 18476 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
INFO 18476 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
INFO 18476 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.46]
INFO 18476 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
INFO 18476 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1087 ms
INFO 18476 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page template: index
WARN 18476 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\xxx\target\classes\mappers\ArticleMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [E:\xxx\target\classes\mappers\ArticleMapper.xml]'. Cause
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值