Spring Boot启动失败 BeanDefinitionStoreException

初学Spring Boot,启动时失败:

** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/cmc/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.2.5.RELEASE/spring-boot-autoconfigure-1.2.5.RELEASE.jar!/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$JdbcTemplateConfiguration.class]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration due to internal class not found. This can happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)

CSDN小伙伴提出的解决方案:

查了半天终于才stack overflow上看到了解决方案,链接如下:stack overflow
是因为application.java 文件不能直接放在main/java文件夹下,必须要建一个包把他放进去

官方文档有一小段说明:

When a class does not include a package declaration, it is considered to be in the “default package”. The use of the “default package” is generally discouraged and should be avoided. It can cause particular problems for Spring Boot applications that use the @ComponentScan@EntityScan, or @SpringBootApplicationannotations, since every class from every jar is read.


记录一下学习中遇到的问题踩过的坑

根据引用和引用的信息,你的错信息是org.springframework.beans.factory.BeanDefinitionStoreException。这个异常通常是由于pom文件的依赖配置问题导致的。具体的错误原因可以通过详细的错信息(caused by)找到。在你的错信息中,关键的错信息是:Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.actuate.autoconfigure.audit.AuditEventsEndpointAutoConfiguration due to org/springframework/core/annotation/MergedAnnotations$SearchStrategy not found. Make sure your own configuration does not rely on that class. 根据引用的提示,你可以查看pom文件中关于actuator的依赖配置,确保依赖配置正确。具体的依赖配置可以通过以下代码示例来进行检查: ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> <version>2.2.7.RELEASE</version> </dependency> ``` 如果你已经确认依赖配置正确,但问题仍然存在,你可以尝试查看Spring Cloud官方网站(https://projects.spring.io/spring-cloud/)获取更多关于nacos服务启动错的解决方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Springcloud中服务启动失败错:org.springframework.beans.factory.BeanDefinitionStoreException](https://blog.csdn.net/baidu_38769016/article/details/106151236)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [springcloud 入门第一坑[org.springframework.beans.factory.BeanDefinitionStoreException: Failed to ...](https://blog.csdn.net/u012930316/article/details/79578006)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值