简体   繁体   中英

generate executable spring boot jar

I'm using spring boot for deploying an application

in my pom i have :

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

It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file

I recompiled the Jar with the command mvn package spring-boot:repackage -Pdev

and all is ok.

I don't know it doesn't work when compiling with the usual command 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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