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

Failed to get nested archive for entry BOOT-INF/lib/spring-kafka-2.2.7.RELEASE.jar

时间:2019-12-07 16:26:05      阅读:812      评论:0      收藏:0      [点我收藏+]

标签:ESS   swagger   swa   jdk8   fat   kafka   arc   mave   hid   

环境:

springboot + kafka + ES 。。。。。。

maven3.6

jdk8

问题是 jar包启动失败报错,错误如下:

Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/spring-kafka-2.2.7.RELEASE.jar
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:108)
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:86)
        at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:70)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.io.IOException: Unable to open nested jar file ‘BOOT-INF/lib/spring-kafka-2.2.7.RELEASE.jar‘
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:256)
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:241)
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103)
        ... 4 more
Caused by: java.lang.IllegalStateException: Unable to open nested entry ‘BOOT-INF/lib/spring-kafka-2.2.7.RELEASE.jar‘. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
        at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:284)
        at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:264)
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:252)
        ... 6 more

pom.xml文件如下

        <!-- spring-boot-starter-data-elasticsearch -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
        <!-- elasticsearch-rest-high-level-client -->
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
        </dependency>

        <!--swagger2-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.6.1</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.6.1</version>
        </dependency>

        <!-- devtools -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <!--sofaboot测试插件-->
        <dependency>
            <groupId>com.alipay.sofa</groupId>
            <artifactId>test-sofa-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- mybatis -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
               <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals><goal>shade</goal></goals>
                            <configuration>
                                <relocations>
                                    <relocation>
                                        <pattern>org.apache.http</pattern>
                                        <shadedPattern>hidden.org.apache.http</shadedPattern>
                                    </relocation>
                                    <relocation>
                                        <pattern>org.apache.logging</pattern>
                                        <shadedPattern>hidden.org.apache.logging</shadedPattern>
                                    </relocation>
                                    <relocation>
                                        <pattern>org.apache.commons.codec</pattern>
                                        <shadedPattern>hidden.org.apache.commons.codec</shadedPattern>
                                    </relocation>
                                    <relocation>
                                        <pattern>org.apache.commons.logging</pattern>
                                        <shadedPattern>hidden.org.apache.commons.logging</shadedPattern>
                                    </relocation>
                                </relocations>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
    </build>
    <repositories>

错误原因分析:

Pom中采用了maven-shade-plugin,最终生成了fat包,超过Spring Boot Loader的上限。因此,在B模块的Pom中直接移除了maven-shade-plugin插件,使得该依赖大小符合要求。

解决办法:

注释掉红圈的plugin。

技术图片

 

 

Failed to get nested archive for entry BOOT-INF/lib/spring-kafka-2.2.7.RELEASE.jar

标签:ESS   swagger   swa   jdk8   fat   kafka   arc   mave   hid   

原文地址:https://www.cnblogs.com/lfyu/p/12001968.html

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