Maven 无法使用 OpenJDK 11 找到 jaxb-api,即使它存在于存储库中

Ish*_*ogi 5 java maven spring-boot java-11

我有一台装有 Windows 操作系统的机器,它用于构建一些 WAR 项目。它上面安装了 Java 8 。我正在使用Maven 3.2.5来构建这些 WAR 项目。一切正常。但由于 Java 8 由于免费更新的结束而在未来会成为一个问题,所以我考虑升级到 OpenJDK 11。

我下载了 OpenJDK 11,但没有安装它,因为我只是想尝试启动其中一个项目。我选择了一个 WAR 项目来检查 OpenJDK 11 是否有效。该项目是使用 JHipster 和 Spring Boot 创建的。我更改了该项目要使用的 pom.xml,spring-boot.version to 2.1.2并且java.verion to 11还放置了jaxb-api, jaxb-impl, jaxb-runtimejavax.activation输入项(如下所示)以避免 Java 11 中与 jaxb 相关的依赖项错误。

在 Windows 命令提示符中,我将JAVA_HOMEPATH变量设置为 OpenJDK11,然后触发mvn clean compile package命令。正如预期的那样,所有与 jaxb 相关的依赖项都会下载到 Maven 存储库中,但 Maven 仍然会抛出错误NoClassDefFoundError: javax/xml/bind/JAXBException,而 jaxb-api jar 仍然存在于 Maven 存储库中。我尝试再次发出该命令,但没有成功。

任何人都可以指导我有关可能的根本原因或任何解决方法。

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

Sim*_*mon 1

我使用以下 POM 进行了此操作

<properties>
    <maven-jaxb2-plugin.version>0.14.0</maven-jaxb2-plugin.version>
</properties>
Run Code Online (Sandbox Code Playgroud)

//

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.4.0-b180830.0359</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.activation/activation -->
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.0-b170127.1453</version>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

//

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>${maven-jaxb2-plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
                <schemaIncludes>
                    <include>*.wsdl</include>
                </schemaIncludes>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)