开发SSM项目时报错:BeanCreationException/UnsatisfiedDependencyException

开发SSM项目时报错:org.springframework.beans.factory.BeanCreationException/UnsatisfiedDependencyException

在spring-mybatis.xml配置文件中添加mapperLocations寻找映射配置文件,只要写了对应的classpath*路径会报错,关键是写对了也报错:org.springframework.beans.factory.BeanCreationException:

org.springframework.beans.factory.UnsatisfiedDependencyException:

在spring-mybatis.xml配置文件中是这样配置的

<property name="mapperLocations" value="classpath*:/mybatis/mapper/*.xml"></property>

我以为是我路径写错了,尝试修改了路径为:value="classpath*:**/mapper/*.xml还是报错,最后察觉都是寻找.xml文件后报错的,感觉可能是逆向生成工程的时候,在mapper中的.xml文件中,被我删除或者增加了代码
解决办法:我把逆向生成的文件都删除了,重新生成一次,问题解决。

9月 17, 2025 1:51:05 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service [Tomcat] 9月 17, 2025 1:51:05 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet engine: [Apache Tomcat/9.0.68] 9月 17, 2025 1:51:05 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring embedded WebApplicationContext 25-09-17 13:51:05,748 INFO ServletWebServerApplicationContext:290 - Root WebApplicationContext: initialization completed in 1285 ms Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter. Registered plugin: 'com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor@1288222a' Parsed mapper file: 'file [D:\javaproject\Vue\music\online_music_server\target\classes\mapper\AdminMapper.xml]' Parsed mapper file: 'file [D:\javaproject\Vue\music\online_music_server\target\classes\mapper\CollectMapper.xml]' 25-09-17 13:51:06,006 WARN AnnotationConfigServletWebServerApplicationContext:591 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminMapper' defined in file [D:\javaproject\Vue\music\online_music_server\target\classes\com\niit\online_music_server\mapper\AdminMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.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 [D:\javaproject\Vue\music\online_music_server\target\classes\mapper\ComsumerMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 72; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。 25-09-17 13:51:06,015 INFO ConditionEvaluationReportLoggingListener:136 - Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 9月 17, 2025 1:51:06 下午 org.apache.catalina.core.StandardService stopInternal 信息: Stopping service [Tomcat] 25-09-17 13:51:06,030 ERROR SpringApplication:835 - Application run failed
最新发布
09-18
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值