运行jar提示没有主清单属性
解决方法:
1.最简单方法
右键jar,使用压缩包打开(我使用360压缩),找到META-INF下的MANIFEST.MF,在最后一行加主清单:
Main-Class: com.bx.Main 其中Main-Class:由空格,com.bx.Main是我main方法类的路径
2.如果时maven项目,就在pom中<project>添加,其中com.bx.Main是我的启动类:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.bx.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
3.如果时springboot项目就在pom添加:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<!-- spring热部署-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.7.RELEASE</version>
</dependency>
</dependencies>
</plugin>
本文链接:http://www.yayihouse.com/yayishuwu/chapter/1659