我正在尝试设置一个简单的项目,它应该使用cxf-xjc-plugin生成xsdtojava。该项目还使用了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>发布于 2018-11-28 15:39:33
看起来是Ubuntu上的Java出了点问题。今天更新到OpenJDK 64位服务器VM (内部版本10.0.2+13-Ubuntu-1ubuntu0.18.04.4,混合模式)修复了这个问题。
在更新之前,- cxf插件总是在forked模式下运行,并且它无法在/tmp/中正确创建jar归档。在写权限等方面没有问题,但是出于某种原因,这个归档中没有jars,这就是为什么你得到了ClassNotFoundException。
https://stackoverflow.com/questions/53155027
复制相似问题