Programing

Maven JAXB 플러그인의 차이점

lottogame 2020. 7. 10. 08:19
반응형

Maven JAXB 플러그인의 차이점


Maven 2 두 가지 JAXB 플러그인 이 있으며 구성이 다릅니다.

하나는 Sun : http://jaxb.dev.java.net/jaxb-maven2-plugin/ 이고, 다른 하나는 Mojohaus입니다 : http://mojohaus.org/jaxb2-maven-plugin/

이 두 플러그인 중 어떤 것을 추천 할 수 있습니까?


고마워 매트. 내 작은 연구 프로젝트에서 나는 sunners에서 오는 또 다른 플러그인이 있음을 발견했습니다.

<groupId>com.sun.tools.xjc.maven2</groupId>  
<artifactId>maven-jaxb-plugin</artifactId>  

그리고 저것 :

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

그리고 여전히 Codehouse의 것입니다.


요약하자. 우리는 :

  1. 받는다는-JAXB2 - 플러그인 ( https://github.com/highsource/maven-jaxb2-plugin )
  2. 받는다는 - JAXB - 플러그인 ( https://jaxb.dev.java.net/jaxb-maven2-plugin/ )
  3. JAXB2 - 받는다는 - 플러그인 ( https://github.com/mojohaus/jaxb2-maven-plugin )

이 스레드 의 의견을 바탕으로 항상 maven-jaxb2-plugin (예 : 플러그인 # 1)을 사용했습니다.

내 관점에서 org.jvnet.jaxb2.maven2 : maven-jaxb2-plugin 대 com.sun.tools.xjc.maven2 : maven-jaxb-plugin에 관해서는 분명히 첫 번째입니다 ( http : // maven-jaxb2 -plugin.java.net/ ).

이 플러그인은 com.sun.tools.xjc.maven2 : maven-jaxb-plugin보다 훨씬 많은 기능을 가지고 있으며 개발이 활발합니다. 마지막으로 저자 중 하나입니다.) JAXB 개발자 및 사용자와 계속 연락하고 최신 기능 / 요청에 반응한다고 말하고 싶습니다.

실제로 플러그인 # 2는 매우 활성 적이 지 않습니다 (죽었습니까?). 그리고 나는 항상 # 1에 만족했기 때문에 플러그인 # 3을 사용한 적이 없으므로 실제로 그것에 대해 아무 말도 할 수 없습니다. 플러그인 # 1의 작동 구성은 다음과 같습니다.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <inherited>true</inherited>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

최근에 위에서 언급 한 세 가지 플러그인을 시도했습니다 (여기에 포함).

  1. maven-jaxb2-plugin ( http://maven-jaxb2-plugin.java.net/ )
  2. maven-jaxb-plugin ( https://jaxb.dev.java.net/jaxb-maven2-plugin/)
  3. jaxb2-maven-plugin ( http://mojo.codehaus.org/jaxb2-maven-plugin/ )

CXF XJC Maven Plugin http://cxf.apache.org/cxf-xjc-plugin.html : 네 번째 옵션을 사용하여 끝났습니다 .

If I am missing something I would like to know, but the configuration seemed more straightforward for what I was trying to do and more easily allowed me to to deal with duplicate class generation within the same namespace -- similar to this question: Is there a way to deal with duplicate element definitions across multiple .xsd files in JAXB?.

I now have granular control over each incoming XSD and corresponding java package; here is a sample configuration close to the one I am using.

 <plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-xjc-plugin</artifactId>
    <version>2.3.0</version>
    <configuration>
        <extensions>
            <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0</extension>
        </extensions>
    </configuration>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>xsdtojava</goal>
            </goals>
            <configuration>
                <sourceRoot>${basedir}/target/generated-sources/src/main/java</sourceRoot>
                <xsdOptions>
                    <xsdOption>
                        <xsd>src/main/resources/schema/commands.xsd</xsd> <!--shares a common.xsd file causing the conflicts-->
                        <packagename>com.foo.bar.commands</packagename>
                    </xsdOption>
                    <xsdOption>
                        <xsd>src/main/resources/schema/responses.xsd</xsd>
                        <packagename>com.foo.bar.responses</packagename>
                    </xsdOption>
                </xsdOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

I am the author of maven-jaxb2-plugin.

The maven-jaxb2-plugin currently uses JAXB 2.1. In the next versions we'll also provide JAXB 2.0 and JAXB 2.2 versions.

As for "which plugin is better" discussion, check the features, decide yourself. Let me know if you miss some functionality.


  • maven-jaxb2-plugin uses the JAXB reference implementation by Oracle/Sun
  • cxf and jaxb2-maven-plugin use Apache Xerces

On a slight tangent: there was a problem with use of maven-jaxb2-plugin with Eclipse Indigo that I posted here. A fix (extension) has recently become available.

This is not meant to disagree, at all, with the recommendation of maven-jaxb2-plugin over maven2-jaxb-plugin. I don't know, but I expect that maven2-jaxb-plugin has the same problem, probably unresolved.


I would guess that one is for the original JAXB specification and the codehaus one is for the JAXB 2.1 specification (and if the dev.java.net would load some time this century, I'd be able to say for sure).

참고URL : https://stackoverflow.com/questions/2432859/difference-of-maven-jaxb-plugins

반응형