简体   繁体   English

生成可执行的Spring Boot jar

[英]generate executable spring boot jar

I'm using spring boot for deploying an application 我正在使用Spring Boot部署应用程序

in my pom i have : 在我的pom中,我有:

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <mainClass>package.MainBootApp</mainClass>
                        </configuration>

                    </execution>
                </executions>
            </plugin>

the compilation with mvn clean install -Pdev comes with build success but when i try to run the jar with java -jar , it cannot started and i got error about : 使用mvn clean install -Pdev进行的编译成功生成,但是当我尝试使用java -jar运行jar时,它无法启动,并且出现以下错误:

It has been compressed and nested jar files must be stored without compression. 它已被压缩,嵌套的jar文件必须未经压缩地存储。 Please check the mechanism used to create your executable jar file 请检查用于创建可执行jar文件的机制

I recompiled the Jar with the command mvn package spring-boot:repackage -Pdev 我使用命令mvn package spring-boot:repackage -Pdev重新编译了Jar

and all is ok. 一切都很好。

I don't know it doesn't work when compiling with the usual command mvn clean install 我不知道用通常的命令mvn clean install编译时不起作用

Any idea ? 任何想法 ?

Can you try this 你可以试试这个吗

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>package.MainBootApp</mainClass>
                    <layout>ZIP</layout>
                </configuration>
            </plugin>
        </plugins>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM