SpringBoot项目报错解决:“Error starting ApplicationContext. To display the conditions report re-run …”
作者:快盘下载 人气:大家好,又见面了,我是你们的朋友全栈君。
SpringBoot项目报错:Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
以下方案80%可以帮助您解决这些个‘可恶的’问题
报错内容和截图如下:
Connected to the target VM, address: '127.0.0.1:4963', transport: 'socket' . ____ _ __ _ _ / / ___'_ __ _ _(_)_ __ __ _ ( ( )___ | '_ | '_| | '_ / _` | / ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |___, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.3.10.RELEASE) 2021-12-25 14:52:41.578 INFO 13204 --- [ main] m.c.DiitMicrosoftserviceCheckApplication : Starting DiitMicrosoftserviceCheckApplication on 老云的计算机 with PID 13204 (D:svnworkspace_nxzrbhdztGh_yizhangtudit-check argetclasses started by liuyundashen in D:svnworkspace_nxzrbhdztGh_yizhangtudit-check) 2021-12-25 14:52:41.583 INFO 13204 --- [ main] m.c.DiitMicrosoftserviceCheckApplication : No active profile set, falling back to default profiles: default 2021-12-25 14:52:43.485 INFO 13204 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2021-12-25 14:52:43.503 INFO 13204 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-12-25 14:52:43.504 INFO 13204 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.45] 2021-12-25 14:52:43.668 INFO 13204 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2021-12-25 14:52:43.668 INFO 13204 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1979 ms 2021-12-25 14:52:43.832 INFO 13204 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource 2021-12-25 14:52:43.910 ERROR 13204 --- [ main] com.alibaba.druid.pool.DruidDataSource : testWhileIdle is true, validationQuery not set 2021-12-25 14:52:43.917 INFO 13204 --- [ main] com.alibaba.druid.pool.DruidDataSource : { dataSource-1} inited _ _ |_ _ _|_. ___ _ | _ | | |/|_)(_| | |_ |_)||_|_ / | 3.2.0 2021-12-25 14:52:44.365 WARN 13204 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springFramework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cheakRecordController': Unsatisfied dependency expressed through field 'recordService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TRecordServiceImpl': Unsatisfied dependency expressed through field 'packageService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resultPackageBaseinfoServiceImpl': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'importDB.datasource.url' in value "${importDB.datasource.url}" 2021-12-25 14:52:44.366 INFO 13204 --- [ main] com.alibaba.druid.pool.DruidDataSource : { dataSource-1} closing ... 2021-12-25 14:52:44.368 INFO 13204 --- [ main] com.alibaba.druid.pool.DruidDataSource : { dataSource-1} closed 2021-12-25 14:52:44.372 INFO 13204 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2021-12-25 14:52:44.391 INFO 13204 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-12-25 14:52:44.410 ERROR 13204 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cheakRecordController': Unsatisfied dependency expressed through field 'recordService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TRecordServiceImpl': Unsatisfied dependency expressed through field 'packageService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resultPackageBaseinfoServiceImpl': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'importDB.datasource.url' in value "${importDB.datasource.url}" at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1425) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.10.RELEASE.jar:2.3.10.RELEASE]
——在看到这些个问题的时候,日志基本都会告诉你错误的地方,所以我们大部分可以根据日志报错的信息分析错误的原因:
一、编译出问题
仔细看报出的问题,有没有如:“Description:…” 这样的字眼,没有 “描述”,如上图所示,这种情况下的操作: 1.clean清理一下; 2.然后install重新编译一下 ;
3.也可以用这个命令,重新编译一下
这个时候重新启动,如果还是报同样的错误,打开如下图位置,看是否有编译的文件,如mapper.xml文件,application.yml或者application.properties文件,以及一些配置文件等
——哎!生气,这里发现真的没有mapper和配置文件,只有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>
好的,清理——>打包——>启动——>运行成功,搞定收工
二、请求接口重复
根据日志看出它说路径问题;这样想你写的接口名字是否重复,只有一个斜杠或者没斜杠的情况
加载全部内容