留意:若通过命令窗口报错:java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0,说明你的jdk版本过低无法运行当前SpringBoot项目,则需要升级jdk版本,由于博主设置了jdk1.8和jdk21两个jdk版本,以是设置暂时情况变量的步骤如下:
留意:若通过命令窗口报错:java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0,说明你的jdk版本过低无法运行当前SpringBoot项目,则需要升级jdk版本,由于博主设置了jdk1.8和jdk21两个jdk版本,以是设置暂时情况变量的步骤如下:
测试类必须在SpringBoot引导类的包或子包中,否则会失效,报错: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
解决办法:给@SpringBootTest注解添加classes属性且属性值为SpringBoot引导类