码迷,mamicode.com
首页 > 编程语言 > 详细

在idea中把springboot项目打成jar包遇到的问题(没有主清单属性)(没有内置tomcat)(闪退)

时间:2019-08-31 23:18:42      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:为什么   sse   dea   pid   oal   maven   framework   efault   cut   

在idea中把springboot项目打成jar包遇到的问题:没有主清单属性

也就是你打好的jar包中的META-INF的MANIFEST文件中没有

Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: 入口类权限定名
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/

 

解决方法:加这个插件(标红的一定要自己加上去,因为spring的官方生成文件没有这个)

 

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>

</plugin>
如果还没有解决,就有可能你的pom文件的插件不干净
idea自己生成的maven项目里pom自带的插件会影响打包
比如说:
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<pluginManagement/>
有了这个的项目打jar包时,jar包不会内置tomcat
这也是明明打好包又没报错为什么用命令打开时会报:没有主清单属性或闪退的原因(没有内置到tomcat)

所以打包时要确认自己的pom文件中的插件要干净
 <build>
              <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
    </build>

 

 

在idea中把springboot项目打成jar包遇到的问题(没有主清单属性)(没有内置tomcat)(闪退)

标签:为什么   sse   dea   pid   oal   maven   framework   efault   cut   

原文地址:https://www.cnblogs.com/406070989senlin/p/11440715.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!