运行jar包报没有清单属性
时间: 2023-08-15 18:05:11 浏览: 46
回答: 当你运行一个打包好的Spring Boot项目的jar包时,如果出现"没有主清单属性"的错误,通常有两种可能的原因。一种可能是你的pom.xml文件中没有添加spring-boot-maven-plugin插件,另一种可能是你的插件配置有误。
为了解决这个问题,你可以按照以下步骤进行操作:
1. 确保在你的pom.xml文件中添加了spring-boot-maven-plugin插件。你可以在<build><plugins>标签中添加以下代码:
```
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
```
这个插件的作用是将你的项目打包成可执行的jar包。\[2\]
2. 如果你已经添加了插件但仍然出现错误,那么可能是插件的配置有误。你可以检查一下插件的配置是否正确。你可以在<plugin>标签中添加以下代码:
```
<configuration>
<skip>true</skip>
<finalName>${project.name}</finalName>
</configuration>
```
这个配置将跳过插件的执行,并将最终生成的jar包命名为项目的名称。\[3\]
通过以上步骤,你应该能够解决"没有主清单属性"的错误,并成功运行你的jar包。
#### 引用[.reference_title]
- *1* *2* [springboot 启动jar包报jar中没有主清单属性](https://blog.csdn.net/weixin_43860634/article/details/127675246)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [jar包运行后显示 没有主清单属性](https://blog.csdn.net/weixin_42585386/article/details/115334503)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]