您当前的位置: 首页 >  ar

wu@55555

暂无认证

  • 2浏览

    0关注

    201博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

spingboot项目运行报错:xxx.jar中没有主清单属性

wu@55555 发布时间:2020-12-05 18:27:23 ,浏览量:2

报错

项目为spingboot项目,打包成了jar包。打包时就发现文件太小,只有200多K,一运行果然报错。

解决

pom.xml中添加


				org.springframework.boot
				spring-boot-maven-plugin
				${springboot-version}
				
					
						
							repackage
						
					
				
			

重新打包,发现jar大小正常了,但是再运行出现了另外一个错(这里是我项目的原因,针对如题错误,到此应该解决了)

报错 unsupportedClassVersionError

1、再次运行还是报错

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

关注
打赏
1664985904
查看更多评论
立即登录/注册

微信扫码登录

0.0406s