现象是项目在编译期没有报错 在启动的时候报的错误信息是(debug级别)Failed to introspect @Bean methods on class xxx 和Failed to introspect annotated methods on class xxx
一开始看异常栈栈顶报错是java.lang.NoClassDefFoundError 通过打开-XX:+TraceClassLoading 查看类加载日志 发现这个类确实没有加载成功但是在依赖的jar包中这个类确实是存在的
然后找到打印Failed to introspect @Bean methods on class xxx 和Failed to introspect annotated methods on class xxx的代码 在debug模式下查看异常栈 发现栈顶是一个ClassNotFoundException异常
ClassNotFoundException异常一般就是没有加载对应的jar包了
我出现这个原因是用了一个私有jar包A.jar 这个jar包又依赖其他私有jar包 B.jar 但是这个A.jar包在打包的时候没有包含它的依赖B.jar
在pom里面加上B.jar即可