mavn 项目 no main manifest attribute
时间: 2023-09-26 15:11:58 浏览: 166
Maven 项目生成jar运行时提示“没有主清单属性”
当使用maven打包java程序时,如果在执行java -jar命令时提示"no main manifest attribute",这意味着在打包时没有正确配置主函数main。你可以通过以下方式来解决这个问题。首先,在maven的配置文件中添加如下代码段:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.hisense.main.Main</mainClass> //主程序入口类,可以按住control,单机定位到该类
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
这样做可以确保在打包时正确配置主函数main,从而解决"no main manifest attribute"的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [maven 打包后运行jar文件提示 no main manifest attribute](https://blog.csdn.net/weixin_40762393/article/details/90666692)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [maven-jar包 启动找不到main 报错no main manifest attribute](https://blog.csdn.net/Dolphin_bobo/article/details/117781858)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文