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

在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>
 
 
 

猜你喜欢

转载自www.cnblogs.com/406070989senlin/p/11440715.html
今日推荐