【发布时间】:2014-09-17 09:16:54
【问题描述】:
方法是通过xsd使用jaxb2-maven-plugin生成java类。
pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>${project.groupId}.model</packageName>
<extension>true</extension>
<arguments>-b ${resource.dir}/jaxbbindings.xsd -Xannotate</arguments>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<schemaFiles>1.0.xsd</schemaFiles>
<clearOutputDir>true</clearOutputDir>
</configuration>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.4</version>
</dependency>
<dependency>
<groupId>com.sun.codemodel</groupId>
<artifactId>codemodel</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</plugin>
还有xsd 1.0:
<xs:schema
targetNamespace="http://example.com/1.0"
xmlns:gs="http://example.com/1.0"
xmlns:cmn="http://example.com/another"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="another.xsd"
namespace="http://example.com/another" />
....
</xs:schema>
正如您在导入标签中看到的那样,我打算导入另一个架构。
另一个.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://example.com/another"
xmlns:vt="http://example.com/another">
...
</xs:schema>
所以,如果maven执行XJC通过XSD生成java类,也会生成package-info:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://example.com/another")
package de.fraunhofer.fokus.testing.fokusmbt.specexplorer.model;
正如您在上面看到的,命名空间是http://example.com/another。但这是错误的。命名空间应该是http://example.com/1.0。
其他东西工作正常(生成 java 类等等)。
我做错了什么?
【问题讨论】:
-
你解决了这个问题吗?如果是,你是怎么解决的?