解决Error starting ApplicationContext.To display the conditions report re-run your application xxx的问题
目录
- 1. 配置文件的错误
- 2. 编译的错误
- 3. 定义请求接口重复的错误
- 4. 没加@Mapper注解的错误
- 5. 端口重复错误
- 6. 包冲突的错误
- 7. 总结
- 8. 参看文档
解决Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
的问题。
1. 配置文件的错误
今天在项目启动类中,加上这行代码@MapperScan("com.**.mapper")
后,报出了如下错误:
com.superjson.superjsonmanager.SuperJsonManagerApplication
Connected to the target VM, address: '127.0.0.1:49879', transport: 'socket'. ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )' |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot :: (v2.7.1)2022-08-05 16:37:27.699 INFO 152900 --- [ main] c.s.s.SuperJsonManagerApplication : Starting SuperJsonManagerApplication using Java 1.8.0_102 on DESKTOP-UVTEHFR with PID 152900 (D:\project\1myProject\superjson\superjsonmanager\target\classes started by zby in D:\project\1myProject\superjson\superjsonmanager)
2022-08-05 16:37:27.702 INFO 152900 --- [ main] c.s.s.SuperJsonManagerApplication : No active profile set, falling back to 1 default profile: "default"
2022-08-05 16:37:28.166 WARN 152900 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.**.mapper]' package. Please check your configuration.
2022-08-05 16:37:28.408 INFO 152900 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8088 (http)
2022-08-05 16:37:28.414 INFO 152900 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-08-05 16:37:28.414 INFO 152900 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.64]
2022-08-05 16:37:28.504 INFO 152900 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-08-05 16:37:28.505 INFO 152900 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 772 ms
2022-08-05 16:37:28.719 WARN 152900 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'mybatis-org.mybatis.spring.boot.autoconfigure.MybatisProperties': Could not bind properties to 'MybatisProperties' : prefix=mybatis, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'mybatis.configuration' to org.apache.ibatis.session.Configuration
2022-08-05 16:37:28.721 INFO 152900 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-08-05 16:37:28.729 INFO 152900 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-08-05 16:37:28.740 ERROR 152900 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************
APPLICATION FAILED TO START
***************************Description:Failed to bind properties under 'mybatis.configuration' to org.apache.ibatis.session.Configuration:Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [@org.springframework.boot.context.properties.NestedConfigurationProperty org.apache.ibatis.session.Configuration]Action:Update your application's configurationDisconnected from the target VM, address: '127.0.0.1:49879', transport: 'socket'Process finished with exit code 1
通过分析代码后,发现配置文件出现了问题,如下图所示:
字段configuration
给到了空值,导致spring boot无法获取到对应的值,报出上面的错误。只要把该字段删除即可启动spring boot。
这个错误存在多种情况,如果以上解决方案无法解决你的问题,可以继续查看如下的解决方案,大概能解决你的实际问题。
2. 编译的错误
仔细看报出的问题,有没有具体报错信息,如上图所示,这种情况进行如下操作:
clean清理一下
然后install重新编译一下
- 也可以用这个命令,重新编译一下
此时,清除缓存后重新启动,如下图所示:
如果还报同样的错误,打开如下图位置,看是否有编译的文件,如mapper.xml
文件,application.yml
或者application.properties
文件,以及一些配置文件等
这里发现真的没有mappe
r和配置文件,只有main下面的.jar文件
,该怎么办呢?
pom.xml文件
中给加入要编译的文件位置依赖,如下:(这是我的文件位置,你根据你的进行调整)
<!--引入本地资源-->
<resources><!--加载lib文件,特殊情况下会有lib,但大部分都靠依赖下载了--><resource><directory>lib</directory><targetPath>BOOT-INF/lib/</targetPath><includes><include>**/*.jar</include></includes></resource><!--打jar包--><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes></resource><!--将properties和xml文件编译--><resource><directory>src/main/resources</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource>
</resources>
如是,清理 ->打包 -> 启动 -> 运行即可。
3. 定义请求接口重复的错误
日志说明是路径问题,你可以思考下:是不是写的接口名字重复了,或者只有一个斜杠或没斜杠的情况:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'indexController' method
com.superjson.superjsonmanager.controller.IndexController#heart()
to {GET [/heart]}: There is already 'indexController' bean method
com.superjson.superjsonmanager.controller.IndexController#heartbeat() mapped.at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.21.jar:5.3.21]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.21.jar:5.3.21]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.1.jar:2.7.1]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) [spring-boot-2.7.1.jar:2.7.1]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) [spring-boot-2.7.1.jar:2.7.1]at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.7.1.jar:2.7.1]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) [spring-boot-2.7.1.jar:2.7.1]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) [spring-boot-2.7.1.jar:2.7.1]at com.superjson.superjsonmanager.SuperJsonManagerApplication.main(SuperJsonManagerApplication.java:43) [classes/:na]
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'indexController' method
com.superjson.superjsonmanager.controller.IndexController#heart()
to {GET [/heart]}: There is already 'indexController' bean method
com.superjson.superjsonmanager.controller.IndexController#heartbeat() mapped.at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.validateMethodMapping(AbstractHandlerMethodMapping.java:669) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:635) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:332) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod(RequestMappingHandlerMapping.java:420) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod(RequestMappingHandlerMapping.java:76) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$2(AbstractHandlerMethodMapping.java:299) ~[spring-webmvc-5.3.21.jar:5.3.21]at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:1.8.0_102]at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:297) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.processCandidateBean(AbstractHandlerMethodMapping.java:266) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:225) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:213) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:205) ~[spring-webmvc-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.21.jar:5.3.21]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.21.jar:5.3.21]... 16 common frames omitted
如下截图:
修改如下:
重新启动即可。
4. 没加@Mapper注解的错误
这些情况就是看描述的问题,如图所示:
这种情况,看是不是没有扫描到它需要的东西,给加上@Mapper注解
(扫描dao层的),或者加上@Service
注解(扫描service层)即可。
5. 端口重复错误
查看是否自己的运行端口冲突,将其kill杀死,重新启动,或者跟换端口。
以下是查看端口冲突的方式:
window键+R
,输入netstat -aon|findstr 8080
找到占用8080
端口的进程号:
- 输入
tasklist|findstr "3412"
,查看进程号为3412
的进程:
- 输入
taskkill /f /t /im QQ.exe
:(/f:强制性的结束进程),结束这个进程:
现在,可以重新启动一下,看是否运行成功。
6. 包冲突的错误
如果是包冲突,可以将maven仓库清理一下自己的包,重新下载一下:
7. 总结
如果以上解决方案人,仍旧无法解决你的问题,而你其他方式解决了,可以在评论区评论,大家一起快乐地成长。
8. 参看文档
https://blog.csdn.net/m0_50762431/article/details/122143601
解决Error starting ApplicationContext.To display the conditions report re-run your application xxx的问题相关推荐
- Error starting ApplicationContext. To display the conditions report re-run your application 排查
jar包启动项目失败,并报错:Error starting ApplicationContext. To display the conditions report re-run your appli ...
- error starting applicationcontext. to display the conditions report re-run y完美解决
Error starting ApplicationContext. To display the conditions report re-run y 1.加conponent注解 今天在启动spr ...
- SpringBoot项目报错解决:“Error starting ApplicationContext. To display the conditions report re-run ...”
SpringBoot项目报错:Error starting ApplicationContext. To display the conditions report re-run your appli ...
- 报错,Error starting ApplicationContext. To display the conditions report re-run your application with
问题: Error starting ApplicationContext. To display the conditions report re-run your application with ...
- SpringBoot报错:Error starting ApplicationContext. To display the conditions report re-run your applica
Spring Boot报错:Error starting ApplicationContext. To display the conditions report re-run your applic ...
- springboot错误:Error starting ApplicationContext. To display the conditions report re-run your applica
springboot错误:Error starting ApplicationContext. To display the conditions report re-run your applica ...
- springboot启动报错:Error starting ApplicationContext. To display the conditions report re-run your appl
Spring Boot启动时,报错如下: *************************** APPLICATION FAILED TO START *********************** ...
- 启动springboot报Error starting ApplicationContext. To display the conditions report re-run your applica
Web server failed to start. Port 8080 was already in use. 说明端口8080已在使用中. 这时只需要在配置文件properties或者yml中配 ...
- Error starting ApplicationContext. To display the auto-configuration report re-run your application
application.yml debug: true # 默认false application.properties debug = true //默认false
最新文章
- 极路由为何获MTK临幸?
- 使用FAI+PXE批量部署Debian。
- shop--10.商品--商品添加(前端)及问题的解决
- add to -append Backend implementation
- 【剑指offer】面试题55 - I. 二叉树的深度(java)
- 蜜汁问题?差异基因分析谁比谁有差别吗?
- Hibernate框架 一对多,多对多映射
- python LIST学习
- Hibernate学习(一)创建数据表
- 从零基础入门Tensorflow2.0 ----三、6. 实战tf.constant
- vmware linux ssh密码,使用 SSH 密钥连接到 Linux VM - Azure Linux Virtual Machines | Azure Docs...
- android sns空间代码,Android视频分享SNS类APP完整源码(服务端+客户端)
- CQF笔记Primer金融基础
- 不定积分知识结构图_不定积分计算法则总结
- php 面向对象知识体系
- torch.cat()函数的官方解释,详解以及例子
- 第25届ccf-csp认证赛后
- 非科编程逆袭国外名校计算机专业,三本生预科逆袭世界前100名校!H同学喜获3大计算机专业本科录取...
- 大数据的过去、现在和未来:万字长文解读《大数据四十二条》
- android相机分辨率是多少合适,相机像素高一定好吗 相机像素多少合适【详解】...