springboot jar打包 no main manifest attribute

有2种方式

  • 使用mvn

利用以下命令进行打包的

mvn compile

就是要先编译进来,才能把项目中的class文件加进来
之后执行以下代码

mvn package spring-boot:repackage
  • 使用spring-boot maven-plugin

https://docs.spring.io/spring-boot/docs/2.7.4/maven-plugin/reference/htmlsingle/

Packaging Executable Archives
The plugin can create executable archives (jar files and war files) that contain all of an application’s dependencies and can then be run with java -jar.

Packaging an executable archive is performed by the repackage goal, as shown in the following example:

<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>
posted @ 2022-09-25 22:44  liujw2001  阅读(405)  评论(0)    收藏  举报