报错
项目为spingboot项目,打包成了jar包。打包时就发现文件太小,只有200多K,一运行果然报错。
解决pom.xml中添加
org.springframework.boot
spring-boot-maven-plugin
${springboot-version}
repackage
重新打包,发现jar大小正常了,但是再运行出现了另外一个错(这里是我项目的原因,针对如题错误,到此应该解决了)
报错 unsupportedClassVersionError1、再次运行还是报错
unsupportedClassVersionError PreView features are not enabled for xxx try running with '--enable-preview'
根据提示,以–enable-preview运行项目,但是还是报错
去掉了pom.xml中enable-preview属性
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
UTF-8
14
11
11
org.springframework.boot
spring-boot-maven-plugin
${springboot-version}
repackage
org.apache.maven.plugins
maven-surefire-plugin
3.0.0-M5
2、打包运行又报错
jdbcTemplate that could not found
去掉了启动类中@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) 里的(exclude= {DataSourceAutoConfiguration.class}) 注:exclude是在服务中不需要访问数据库时添加,如果需要访问则不要添加
又报错
failed to configure a datasource 'url' attributu is not specified and no embedded datasource
添加了resources目录的扫描
src/main/java
**/*.xml
false
src/main/resources
**/*.yml
**/*.properties
**/*.xml
false
运行成功 问题解决
参考【1】https://blog.csdn.net/zhenghhgz/article/details/88530524