SpringBoot项目报错解决:“Error starting ApplicationContext. To display the conditions report re-run …”

SpringBoot项目报错解决:“Error starting ApplicationContext. To display the conditions report re-run …”SpringBoot项目报错:ErrorstartingApplicationContext.Todisplaytheconditionsreportre-runyourapplicationwith’debug’enabled.以下方案80%可以帮助您解决这些个‘可恶的’问题报错内容和截图如下:ConnectedtothetargetVM,address:’127.0.0.1:4963′,transport:’socket’.____

大家好,又见面了,我是你们的朋友全栈君。

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:\svn\workspace_nxzrbhdzt\Gh_yizhangtu\dit-check\target\classes started by liuyundashen in D:\svn\workspace_nxzrbhdzt\Gh_yizhangtu\dit-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>

好的,清理——>打包——>启动——>运行成功,搞定收工


二、请求接口重复

根据日志看出它说路径问题;这样想你写的接口名字是否重复,只有一个斜杠或者没斜杠的情况
在这里插入图片描述
如下截图:
在这里插入图片描述
修改如下:
在这里插入图片描述

好的,重新启动,搞定收工


三、加@Mapper注解

这些情况就是看描述的问题
如图:
在这里插入图片描述
这种情况,看是不是没有扫描到它需要的东西,给加上@Mapper注解(是扫描dao层的),或者 加上@Service注解(扫描service层)即可。


四、加@SpringBootApplication注解,数据库问题

根据问题看出:springboot启动时会自动注入数据源和配置jpa ,解决:
在@SpringBootApplication中排除其注入
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
在这里插入图片描述


五、端口重复问题

查看是否自己的运行端口冲突,将其kill杀死,重新启动,或者跟换端口

以下是查看端口冲突的方式:

  1. window键+R,输入“netstat -aon|findstr 8080”找到占用8080端口的进程号:
    在这里插入图片描述
    2.输入“tasklist|findstr “3412” ”:

    查看进程号为“3412”的进程:
    在这里插入图片描述
    3.输入“taskkill /f /t /im QQ.exe”:(/f:强制性的结束进程)

    结束这个进程
    在这里插入图片描述

现在可以重新启动一下,看是否运行成功


六、包冲突

还有的情况可能是包冲突了,可以将maven仓库清理一下自己的包,重新下载一下
在这里插入图片描述
希望可以帮助到您

~感谢您的光临~

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/161169.html原文链接:https://javaforall.net

(0)
上一篇 2022年7月18日 下午3:16
下一篇 2022年7月18日 下午3:16


相关推荐

  • Java实现两数之和「建议收藏」

    Java实现两数之和「建议收藏」给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。即:每个index上的数字只能用一次示例:给定nums=[2,7,11,15],target=9因为nums[0]+nums[1]=2+7=9所以返回[0,1]方法一:暴力法遍历每个元素x,并查找是否存在一个值与target…

    2022年6月14日
    29
  • gtest宏列表_指定宏怎么用

    gtest宏列表_指定宏怎么用简介总结gtest中的所有断言相关的宏。gtest中,断言的宏可以理解为分为两类,一类是ASSERT系列,一类是EXPECT系列。一个直观的解释就是:ASSERT_*系列的断言,当检查点失败时,退出当前函数(注意:并非退出当前案例)。EXPECT_*系列的断言,当检查点失败时,继续往下执行。布尔值检查FatalassertionNonfatalassertion…

    2026年4月18日
    3
  • conda pycharm 虚拟环境_PyCharm远程调试

    conda pycharm 虚拟环境_PyCharm远程调试软硬件环境 ubuntu18 0464bitpycha 1 2windows1064 7 前言首先说说我的环境 2 台电脑 一台是笔记本 安装的是 windows 系统 主要撸代码和写文档 另一个性能更好些 带 GPU 跑的是 ubuntuserver 写 python 的主力 IDE 是 pycharm 刚好 pycharm 也有远程 deb

    2026年3月27日
    2
  • RPC协议与Http协议区别[通俗易懂]

    RPC协议与Http协议区别[通俗易懂]RPC调用RPC是远程过程调用(RemoteProcedureCall)的缩写形式。SAP系统RPC调用的原理其实很简单,有一些类似于三层构架的C/S系统,第三方的客户程序通过接口调用SAP内部的标准或自定义函数,获得函数返回的数据进行处理后显示或打印。本地过程调用:如果需要完成业务逻辑,则直接去调用本地的方法即可.远程过程调用:我想完成一个业务的调用,但是该功能我没有办法直接调用,需要通过第三方帮助我完成业务规则.具体用法:RPC不关注具体的实现规则,用户也不需要了解具体的协议.谁调用谁

    2022年5月19日
    250
  • java笔试题大全带答案_java笔试题大全带答案(经典11题)[通俗易懂]

    java笔试题大全带答案_java笔试题大全带答案(经典11题)[通俗易懂]#java笔试题大全带答案(经典11题)**1.不通过构造函数也能创建对象吗()**A.是B.否**分析:答案:A**Java创建对象的几种方式(重要):(1)用new语句创建对象,这是最常见的创建对象的方法。(2)运用反射手段,调用java.lang.Class或者java.lang.reflect.Constructor类的newInstance()实例方法。(3)调用对象的clo…

    2022年6月21日
    30
  • java适合女生学吗_【软帝学院】女生不适合学习java?其实女生学java更有优势,更好就业!…[通俗易懂]

    java适合女生学吗_【软帝学院】女生不适合学习java?其实女生学java更有优势,更好就业!…[通俗易懂]女生适合学java吗?女生做IT怎么样首先要表明我的观点,编程是不分男女,什么女生不适合学编程的说法,从客观上来说,我觉得这是一种偏见。不少人潜意识里认为女生不适合从事IT开发岗位的工作,因为他们觉得这些岗位对逻辑性的要求很好,而且要具备一定的操作水平,而女生在这方面比较薄弱。实际上,女生从Java的工作,很多时候能做得比男生更好。为什么说女生比男生更能学好java呢?1、女生往往比男生更细心,我…

    2022年7月7日
    32

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号