码上敲享录 > java入门知识分享 > 运行jar提示没有主清单属性

运行jar提示没有主清单属性

上一章章节目录下一章 2018-10-29已有3072人阅读 评论(0)

运行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


向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交