部署 Spring .ear 时常量池标记无效

Invalid constant pool tag when deploying Spring .ear

在我的工作中,我们需要部署一个 .ear 文件,它必须是 java8。但是当我们尝试部署时,出现了这个错误:

Caused by: com.sap.engine.library.bytecode.cf.CFException: Invalid constant pool tag, 19 at index 4.
    at com.sap.engine.library.bytecode.cf.CFParser.parse0(CFParser.java:386)
    at com.sap.engine.library.bytecode.cf.CFParser.parse(CFParser.java:307)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.parseClassInformation(ClassInfoReaderImpl.java:336)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.traverseZipFile(ClassInfoReaderImpl.java:287)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.readInternal(ClassInfoReaderImpl.java:105)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.traverseFolder(ClassInfoReaderImpl.java:175)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.readInternal(ClassInfoReaderImpl.java:103)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.traverseFolder(ClassInfoReaderImpl.java:175)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.readInternal(ClassInfoReaderImpl.java:103)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.traverseWarFile(ClassInfoReaderImpl.java:196)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.traverseFolder(ClassInfoReaderImpl.java:165)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.readInternal(ClassInfoReaderImpl.java:103)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.traverseFolder(ClassInfoReaderImpl.java:173)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.readInternal(ClassInfoReaderImpl.java:103)
    at com.sap.lib.javalang.tool.impl.ClassInfoReaderImpl.read(ClassInfoReaderImpl.java:95)
    at com.sap.engine.services.deploy.ear.jar.DplArchiveReader.parseAnnotations(DplArchiveReader.java:62)
    at com.sap.engine.services.deploy.ear.jar.EARReader.read(EARReader.java:243)
    at com.sap.engine.services.deploy.server.application.DeployUtilTransaction.prepareNewDeploymentInfo(DeployUtilTransaction.java:251)
    at com.sap.engine.services.deploy.server.application.DeploymentTransaction.begin(DeploymentTransaction.java:199)
    at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhasesOnOneServer(ApplicationTransaction.java:423)
    ... 16 more

我们认为触发此问题是因为其中一个依赖项指向某些 java 9 库。所以我需要有关必须降级哪些依赖项或其他任何内容的帮助,以便将系统部署到 java 8.

这是pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>cl.test</groupId>
    <artifactId>Gestio</artifactId>
    <version>0.9.3</version>
    <packaging>war</packaging>
    <name>Gestión</name>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath />
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            </dependency>

        <!-- https://mvnrepository.com/artifact/com.microsoft.azure/azure-active-directory-spring-boot-starter -->
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-active-directory-spring-boot-starter</artifactId>
            <version>2.1.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-mail -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            </dependency>

        <!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-client -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-client</artifactId>
            </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-jose -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-jose</artifactId>
            </dependency>

        <!-- https://mvnrepository.com/artifact/com.microsoft.azure/adal4j -->
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>adal4j</artifactId>
            <version>1.6.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.nimbusds/oauth2-oidc-sdk -->
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>oauth2-oidc-sdk</artifactId>
            <version>5.64.4</version>
            <scope>runtime</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.webjars/bootstrap -->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.4.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>

        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
            <version>1.18.8</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity5 -->
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
            </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.4</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/libs/ojdbc6.jar</systemPath>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>qa</id>
            <properties>
                <activatedProperties>qa</activatedProperties>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>qa-agrosuper</id>
            <properties>
                <activatedProperties>qa-agrosuper</activatedProperties>
            </properties>
        </profile>
    </profiles>

    <build>
    <finalName>GestionTransportistas</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>animal-sniffer-maven-plugin</artifactId>
                <version>1.16</version>
                <configuration>
                  <signature>
                    <groupId>org.codehaus.mojo.signature</groupId>
                    <artifactId>java18</artifactId>
                    <version>1.0</version>
                  </signature>
                </configuration>
                <executions>
                    <execution>
                        <id>animal-sniffer</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
              </plugin>

<!--            <plugin> -->
<!--                <artifactId>maven-ear-plugin</artifactId> -->
<!--                <version>3.0.1</version> -->
<!--                <configuration> -->
<!--                  configuration elements goes here -->
<!--                </configuration> -->
<!--              </plugin> -->

        </plugins>
    </build>
</project>

我解决了。 Jaxb jar 有一个在 java 9 中编译的 class。 它必须降级到 2.2.12 才能在 java 8 中部署。 您可以通过将其添加到 pom.xml

来降级它
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.12</version>
</dependency>