我的pom.xml文件具有三个不同的插件:第一个从.xsd生成.java,第二个从文件夹更改.java,第三个删除原始的.java
...
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/java/pt/thales/attracktive/communication/pojo</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/generated-sources/xjc/uk/org/siri/siri</directory>
<filtering>true</filtering>
<includes>
<include>*.java</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>${basedir}/target/generated-sources/xjc/uk/org/siri/siri</directory>
<includes>
<include>**/*.java</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
</project>
问题:
SubscriptionRequest.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://www.siri.org.uk/siri" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.siri.org.uk/siri" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="RequestorRef" type="xs:string" />
<xs:element name="MessageIdentifier" type="xs:string" />
<xs:element name="ConsumerAddress" type="xs:string" />
<xs:element name="SubscriberRef" type="xs:string" />
<xs:element name="SubscriptionIdentifier" type="xs:unsignedByte" />
<xs:element name="InitialTerminationTime" type="xs:dateTime" />
</xs:schema>
和TerminateSubscriptionRequest.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://www.siri.org.uk/siri" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.siri.org.uk/siri" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="RequestTimestamp" type="xs:dateTime" />
<xs:element name="RequestorRef" type="xs:string" />
<xs:element name="SubscriberRef" type="xs:string" />
<xs:element name="SubscriptionRef" type="xs:unsignedByte" />
</xs:schema>~
结果:
[ERROR]解析架构时出错。位置[ 文件:/ C:/Users/rapha/Desktop/Thales/attracktive-master/thales.attracktive.communication/attracktive.communication/src/main/resources/TerminateSubscriptionRequest.xsd {4,54}]。 org.xml.sax.SAXParseException; systemId: 文件:/ C:/Users/rapha/Desktop/Thales/attracktive-master/thales.attracktive.communication/attracktive.communication/src/main/resources/TerminateSubscriptionRequest.xsd; lineNumber:4; columnNumber:54; “ RequestorRef”已经定义
我尝试了不同的操作,但未得到结果,可能是我缺少了一些东西。 感谢您的演讲,如果您能帮助我,请
答案 0 :(得分:0)
要更改软件包,可以对jaxb2插件使用generatePackage
选项,如the plug-ins docs 中所述。
如果您需要更强大的功能(如将不同的架构放入不同的程序包中),则需要使用the jaxb docs中所述的jaxb2绑定文件。
重复元素错误是由于两个文件都在同一命名空间中声明了RequestorRef
元素。
您可以通过以下任一方法解决此问题: