我需要使用最新版本的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,但同样不起作用。
发布于 2011-08-18 20:47:58
以下代码改编自netbeans生成的默认webapp。它使用依赖插件将jars复制到一个临时文件夹,并将该文件夹指定为编译器的批注目录,因此它覆盖了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-10-14 05:10:06
我尝试使用Jörn的解决方案,但看起来maven-jaxb2-plugin继续使用了rt.jar版本,因为我从插件得到了说明信息: INFO JAXB API是从jar:file:/C:/jdk1.6.025/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>发布于 2012-01-12 09:24:54
嘿,我只是想节省人们的时间。
对于从事jaxb-impl工作的人来说,jaxb-impl 2.2.4-1版本修复了2.2.4版本的一个bug,META-INF文件夹下的istack-commons-isn的pom包含了对其父pom 2.4-SNAPSHOT的引用,而它应该是jsut 2.4,因为这个版本不是快照。
<parent>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons</artifactId>
<version>2.4-SNAPSHOT</version>
</parent>因此,如果您不想使用快照,您将使用此错误崩溃,除非您想要添加本地存储库中的所有内容,否则您可能需要手动将此版本更新到jar上的pom中。干杯,曼纽尔。
https://stackoverflow.com/questions/7094574
复制相似问题