jdk版本问题
错误:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [E:\JavaWeb\Project\hmdp\hm-dianping\target\classes\com\hmdp\HmDianPingApplication.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [E:\JavaWeb\Project\hmdp\hm-dianping\target\classes\com\hmdp\HmDianPingApplication.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 61
原因:
使用jdk17运行jdk8的项目时,因为maven3.9.4版本的影响,maven的setting.xml文件中指定了jdk版本,导致每一次编译运行时自动选择了指定的jdk17。(推荐使用3.6.1的maven版本,它未指定jdk版本,项目编译运行时会自动选择jdk版本)
解决:
1、清理maven
2、修改project structure 中的设置
3、设置setting中的java compiler
4、重新构建项目
最后重新运行项目即可