我想在生成的“Doc”类之前生成“@java.lang.SuppressWarnings("all")”。
问题:jaxb2-annotate-plugin 不生成注释。
我的 pom.xml:
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<extension>true</extension>
<arguments>-Xannotate</arguments>
<args>
<arg>-Xannotate</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-annotate-plugin-test-annox-annotations</artifactId>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.4</version>
</dependency>
<dependency>
<groupId>com.sun.codemodel</groupId>
<artifactId>codemodel</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.4</version>
</dependency>
<dependency>
<groupId>com.sun.codemodel</groupId>
<artifactId>codemodel</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb.version}</version>
</dependency>
</dependencies>
<properties>
<jaxb.version>2.2.5-2</jaxb.version>
<jaxb-api.version>2.1</jaxb-api.version>
</properties>
我的 XSD:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="..."
targetNamespace="..." elementFormDefault="qualified"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:annox="http://annox.dev.java.net"
jaxb:version="2.1" jaxb:extensionBindingPrefixes="annox">
<xs:element name="Doc">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<annox:annotate>@java.lang.SuppressWarnings("all")</annox:annotate>
<annox:annotateClass>@java.lang.SuppressWarnings("all")
</annox:annotateClass>
<annox:annotate target="class">@java.lang.SuppressWarnings("all")
</annox:annotate>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element ref="info" />
</xs:sequence>
</xs:complexType>
</xs:element>
我尝试了所有三种方法在 Doc 类之前生成“@java.lang.SuppressWarnings("all")"