人本善良

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

springboot 项目 注意事项

SpringBoot出现下列错误。

Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception


或者

Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception


或者
ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4b9e255: startup date [Wed Jul 26 13:37:27 CST 2017]; root of context hierarchy

 


主要是由于application.java文件没有放在main/java文件夹的原因,因为application.Java 文件不能直接放在main/java文件夹下,必须要建一个包把他放进去
SpringBoot在写启动类的时候如果不使用@ComponentScan指明对象扫描范围,默认指扫描当前启动类所在的包里的对象,如果当前启动类没有包,则在启动时会报错:
Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package错误。


@SpringBootApplication
@ComponentScan(basePackageClasses=MytestApplication.class)
public class MytestApplication {


public static void main(String[] args){
SpringApplication.run(MytestApplication.class, args);
}
}

 

@ComponentScan(basePackageClasses=要扫描类.class所在位置的包)-意思是要扫描哪个类所在的包
---------------------
作者:King-Long
来源:CSDN
原文:https://blog.csdn.net/u011095110/article/details/76144416

posted on   简简单单2018  阅读(457)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
点击右上角即可分享
微信分享提示