我尝试使用从jaxb2-maven-plugin
.
考虑以下最小的 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>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>test</packageName>
<sources>
<source>src/main/resources/schema.xsd</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
而这个最小的模式在src/main/resources/schema.xsd
:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" vc:maxVersion="1.1" vc:minVersion="1.0" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root" type="xs:string"/>
</xs:schema>
调用mvn clean compile
时,项目按预期构建。但是当我使用包含 的路径指定文件时..
,会出现以下错误。当使用没有 的(相对或绝对)路径时 ..
,一切都很好。
C:\dev\test>mvn -f ..\test\pom.xml clean compile
[...]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure: Compilation failure:
[ERROR] /C:/dev/test/target/generated-sources/jaxb/test/ObjectFactory.java:[32,8] duplicate class: test.ObjectFactory
我怎样才能摆脱这个错误并使用构建我的项目mvn -f <some path containing "..">
?