English 中文(简体)
• 如何定制由日本宇宙航空研究开发机构生成的包裹。
原标题:How to customize package-info.java generated by JAXB2
  • 时间:2012-01-12 14:57:10
  •  标签:
  • maven
  • jaxb2

I m using

<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>

生产 来自XSD档案的Java课程。

我补充说

<args>-npa</args>

因此,金字塔不会产生任何更多的包裹——Info.java,但随着这一选择,产生的ava类种类不同(每个元素都加上名称)。

So, I cannot customize the namespace using package-info.java.

在不修改人工生成的档案的情况下,我如何使用习惯名称空间?

问题回答

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>

你们可以通过指导日本宇宙航空研究开发机构-B生成<>条码-info.java<>/条码”来规范名称空间,并在科学、技术和科学研究所中确定目标名称空间。

<xs:schema version="1.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xsi:schemaLocation="http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd"
    targetNamespace="yourTargetNameSpace"
    xmlns="yourTargetNameSpace"
    elementFormDefault="qualified">




相关问题
JavaFX with Maven [closed]

I recently started a JavaFX project, and I d like to use Maven as my compiler/deployment tool. Is there a good tutorial or plugin to integrate JavaFX and Maven?

How to upload jar to respository?

I have jar files that cannot be found on Maven Central repository. I would like to add the jar so I can just include extra tag in my pom.xml file and other developer can use the jar. What are the ...

Debug Maven project in Eclipse with third party sources

I am currently developing a maven project in eclipse. The m2eclipse plugin works beautifully. It even works out of the box with debugging. But when I am debugging open source third party libarries. ...

Could Free Pascal benefit of something like Apache Maven?

Apache Maven is a very popular build and dependency management tool in the Java open source ecosphere. I did some tests to find out if it can handle compiled Free Pascal / Delphi units and found it ...

Run a single test method with maven

I know you can run all the tests in a certain class using: mvn test -Dtest=classname But I want to run an individual method and -Dtest=classname.methodname doesn t seem to work.

Uploading a directory using sftp with Maven

How can I upload a directory - Eclipse update site - using sftp with public key authentication in Maven? For background information: I m using tycho to build an Eclipse plugin and want to get the ...

What are solid NMaven or build servers for .NET alternatives?

Maven had a long history and is well supported in the Java world. NMaven has received a less successful start and has never become as popular in the C#/.NET world as its larger cousin was in the Java ...

热门标签