2

我正在尝试设置一个应该xsdtojava使用生成的简单项目cxf-xjc-plugin。该项目还使用spring-boot.

结果期间mvn package

[INFO] Building jar: /tmp/cxf-xjc-plugin3386923426289303800.jar
[DEBUG] Error: Could not find or load main class org.apache.cxf.maven_plugin.XSDToJavaRunner
[DEBUG] Caused by: java.lang.ClassNotFoundException: org.apache.cxf.maven_plugin.XSDToJavaRunner

这很奇怪,因为在类路径上我可以清楚地看到XSDToJavaRunner.class.

我的 java 项目目录是: javaExecutable = /usr/lib/jvm/java-11-openjdk-amd64/bin/java, 和

java -version显示:OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3, mixed mode)

我尝试将cxf-xjc-plugin, 几个jaxb-*<dependency>按如下方式扔到 maven 节点中,但错误仍然存​​在。我在这里想念什么?

<?xml version="1.0" encoding="UTF-8"?>
<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>com.test</groupId>
    <artifactId>cxfxjc-test</artifactId>
    <version>1.0.0</version>

    <parent>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
       <version>2.0.5.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.11</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-core</artifactId>
            <version>3.2.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-xjc-plugin</artifactId>
            <version>3.2.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-xjc-plugin</artifactId>
                <version>3.2.2</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xsdtojava</goal>
                        </goals>
                        <configuration>
                            <xsdOptions>
                                <xsdOption>
                                    <xsd>src/main/resources/test.xsd</xsd>
                                </xsdOption>
                            </xsdOptions>
                        </configuration>
                    </execution>
                </executions>

                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-xjc-plugin</artifactId>
                        <version>3.2.2</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>
4

1 回答 1

1

看起来这是 Ubuntu 上的 Java 的一些问题。今天对 OpenJDK 64 位服务器 VM 的更新(内部版本 10.0.2+13-Ubuntu-1ubuntu0.18.04.4,混合模式)修复了这个问题。

更新前 - cxf 插件始终以分叉模式运行,并且无法在 /tmp/ 中正确创建 jar 存档。写权限等没有问题,但由于某种原因,这个档案中没有罐子,这就是你得到 ClassNotFoundException 的原因。

于 2018-11-28T07:39:33.313 回答