6

最新バージョンの jaxb: 2.2.4-1 を使用する必要がありますが、maven または maven-jaxb2-plugin は JDK からのものを取得しているようです。

次のようにバージョンを指定してみました。

<configuration>
    <specVersion>2.2</specVersion>
    ...
</configuration>

しかし、ログには次のように書かれています:

[INFO] [jaxb2:generate {execution: common}]
[INFO] Started execution.
[INFO] JAXB API is loaded from the [jar:file:/opt/jdk1.6.0_24/jre/lib/rt.jar!].
[INFO] Detected JAXB API version [2.1].

javax.xml.bind:jaxb-api と com.sun.xml.bind:jaxb-impl の正しいバージョンに依存関係を追加しようとしましたが、役に立ちませんでした。

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

        <dependencies>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.2.4</version>
            </dependency>

            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>2.2.4-1</version>
            </dependency>
        </dependencies>

        <executions>
            <execution>
                <id>common</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <specVersion>2.2</specVersion>
                    ...
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

maven-jaxb22-plugin も使用してみましたが、うまくいきませんでした。

4

3 に答える 3

2

次のコードは、netbeans が生成するデフォルトの webapp から変更されています。依存関係プラグインを使用して jar を一時フォルダーにコピーし、このフォルダーを承認されたディレクトリとしてコンパイラに指定して、jdk の実装をオーバーライドします。

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
</properties>

...

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax.xml.bind</groupId>
                                <artifactId>jaxb-api</artifactId>
                                <version>2.2.4</version>
                                <type>jar</type>
                            </artifactItem>
                            <artifactItem>
                                <groupId>com.sun.xml.bind</groupId>
                                <artifactId>jaxb-impl</artifactId>
                                <version>2.2.4-1</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
于 2011-08-18T12:47:58.173 に答える
0

Jörn のソリューションを使用しようとしましたが、プラグインから [INFO] JAXB API is loaded from the [jar:file] というメッセージが表示されたため、maven-jaxb2-plugin が先に進み、rt.jar バージョンを使用したようです:/C:/jdk1.6.0_25/jre/lib/rt.jar!].

私の失敗したバージョンのソリューションは、依存関係プラグインの使用方法がわずかに異なりますが、それは成功するビルドの一部です...

<properties>
  <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
  <v.jaxb2-api>2.2.4</v.jaxb2-api>
  <v.jaxb2-impl>2.2.4-1</v.jaxb2-impl>
  <v.jaxb2-xjc>2.2.4-1</v.jaxb2-xjc>
  <v.jaxb2-basics-jaxb>2.1.13.MR2</v.jaxb2-basics-jaxb>
</properties>
...
<build>
  <plugins>
    <plugin>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>copy-dependencies</id>
          <phase>validate</phase>
          <goals>
            <goal>copy-dependencies</goal>
          </goals>
          <configuration>
            <outputDirectory>${endorsed.dir}</outputDirectory>
            <excludeTransitive>true</excludeTransitive>
            <includeArtifactIds>jaxb-api,jaxb-impl</includeArtifactIds>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>                        
        <source>1.6</source>
        <target>1.6</target>
        <fork>true</fork>
        <meminitial>256m</meminitial>
        <maxmem>768m</maxmem>
        <compilerArguments>
          <endorseddirs>${endorsed.dir}</endorseddirs>
        </compilerArguments>
      </configuration>
    </plugin>
  </plugins> 
</build>
于 2011-10-13T21:10:06.470 に答える
0

ねえ、私は人々の時間を節約したいだけです。
jaxb-impl、バージョン 2.2.4 のバグを修正することを意味するバージョン jaxb-impl 2.2.4-1 で作業する人々のために、META-INF フォルダーの下の istack-commons-runtime の pom には参照が含まれています。このバージョンはスナップショットではないため、jsut 2.4 である必要があるときに、その親 pom 2.4-SNAPSHOT に。

<parent>
    <groupId>com.sun.istack</groupId>
    <artifactId>istack-commons</artifactId>
    <version>2.4-SNAPSHOT</version>
</parent>

したがって、スナップショットを使用したくない場合は、このエラーが発生します。ローカル リポジトリにすべてを追加する場合を除き、このバージョンを jar の pom に手動で更新する必要がある場合があります。乾杯、マヌエル。

于 2012-01-12T01:24:53.600 に答える