我正在尝试建立一个简单的项目,该项目应使用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>
答案 0 :(得分:1)
看起来这是Ubuntu上Java的问题。今天对OpenJDK 64位服务器VM(内部版本10.0.2 + 13-Ubuntu-1ubuntu0.18.04.4,混合模式)的更新已解决此问题。
更新前-cxf插件始终以分叉模式运行,并且无法在/ tmp /中正确创建jar存档。写入权限等没有问题。但是由于某种原因,此存档中没有jar文件,这就是为什么出现ClassNotFoundException的原因。