正如我已经在标题中描述的那样,当我在资源生成步骤中添加@XmlRootElement注释时,我在从源类访问生成的类时遇到了问题。
我的jaxb2-maven-plugin配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/resources/schemas</schemaDirectory>
<packageName>my.classses</packageName>
<bindingDirectory>${project.basedir}/src/main/resources/xjb</bindingDirectory>
<extension>true</extension>
</configuration>
</plugin>
任何帮助都会有用,谢谢!
答案 0 :(得分:1)
生成的源文件可能位于generated-sources下,默认情况下不会添加为源目录,请尝试使用以下内容:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/DIRNAME</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
只需将DIRNAME
替换为生成的文件所在目录的名称。