Failed to get nested archive for entry BOOT

Wesley13
• 阅读 1257

环境:

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

点赞
收藏
评论区
推荐文章
待兔 待兔
3个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Easter79 Easter79
3年前
tidb集群某个节点报错之:node_exporter
今天启动集群tidb时出现一个错误,是某个tikv节点报错:node\_exporter9100.service failed一个节点的问题会导致整个集群启动失败。去此节点下的日志文件中查找,发现没有什么报错原因。无奈此时只能去系统日志中查看发生了什么问题果然发现了问题Jan1615:35:05ip1723126133
第一天:今天学spring的时候遇到一个错误
具体错误如下:Exceptioninthread"main"org.springframework.beans.factory.NoSuchBeanDefinitionException:Nobeannamed'testDao'isdefinedatorg.springframework.beans.factory.support.D
Wesley13 Wesley13
3年前
java连接zookeeper服务器出现“KeeperErrorCode = ConnectionLoss for ...”
错误信息如下:1Exceptioninthread"main"org.apache.zookeeper.KeeperException$ConnectionLossException:KeeperErrorCodeConnectionLossfor/test2atorg.apache.zookeeper
Wesley13 Wesley13
3年前
RAC环境单实例启动数据库收到ORA
     在RAC环境中,如果你在没有启动节点的集群服务的情况下单实例启动数据库,将收到类似如下的报错:\oracle@rhel1u01\$sqlSQL\Plus:Release10.2.0.5.0ProductiononTueApr215:00:272013Copyright(
Easter79 Easter79
3年前
The following classes could not be excluded because they are not auto
在Springboot启动项目的时候,出现如下错误java.lang.IllegalStateException:Thefollowingclassescouldnotbeexcludedbecausetheyarenotautoconfigurationclasses:org.springframewo
Wesley13 Wesley13
3年前
VBox 启动虚拟机失败
在Vbox(5.0.8版本)启动Ubuntu的虚拟机时,遇到错误信息:NtCreateFile(\\Device\\VBoxDrvStub)failed:0xc000000034STATUS\_OBJECT\_NAME\_NOT\_FOUND(0retries) (rc101)Makesurethekern
Stella981 Stella981
3年前
Hbase启动hbase shell运行命令报Class path contains multiple SLF4J bindings.错误
1:Hbase启动hbaseshell运行命令报ClasspathcontainsmultipleSLF4Jbindings.错误,是因为jar包冲突了,所以对于和hadoop的jar包冲突的,可以将其他jar包删除,如果你不确定是否删除正确,可以将其他的jar包复制备份或者修改名称,确保操作以后失败了,还可以找回。SLF4J:Cl
Stella981 Stella981
3年前
SpringBoot2.1.3修改tomcat参数支持请求特殊符号
最近遇到一个问题,比如GET请求中,key,value中带有特殊符号,请求会报错,见如下URL:http://xxx.xxx.xxx:8081/aaa?key1val1&a.\\.id123&ba\1\现在,我们进入boot启动类,添加如下代码即可:publicclassDemoApp{   publicstatic
Easter79 Easter79
3年前
SpringBoot2.1.3修改tomcat参数支持请求特殊符号
最近遇到一个问题,比如GET请求中,key,value中带有特殊符号,请求会报错,见如下URL:http://xxx.xxx.xxx:8081/aaa?key1val1&a.\\.id123&ba\1\现在,我们进入boot启动类,添加如下代码即可:publicclassDemoApp{   publicstatic