You may use the namespace-prefix plugin from jaxb2-common project (disclaimer : I wrote it) :
https://github.com/Siggen/jaxb2-namespace-prefix”rel=“noreferer”>https://github.com/Siggen/jaxb2-namespace-prefix
这是一种Xjc的 p,可以界定名称空间——和;在 具有约束力s.xml文档中预先确定地图:
<jxb:bindings schemaLocation="eCH-0007-3-0.xsd">
<jxb:schemaBindings>
<jxb:package name="ch.ech.ech0007.v3" />
</jxb:schemaBindings>
<jxb:bindings>
<namespace:prefix name="eCH-0007" />
</jxb:bindings>
</jxb:bindings>
产生以下文件: 包装-info.java(含XmlNs annotation)
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.ech.ch/xmlns/eCH-0007/3", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://www.ech.ch/xmlns/eCH-0007/3", prefix = "eCH-0007-3")
})
package ch.ech.ech0007.v3;
页: 1 希望:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<catalog>src/main/resources/catalog.xml</catalog>
<schemaIncludes>
<include>*.xsd</include>
</schemaIncludes>
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<include>bindings.xml</include>
</bindingIncludes>
<args>
<arg>-extension</arg>
<arg>-Xnamespace-prefix</arg>
</args>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-namespace-prefix</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>