我一直在尝试读取存储在target/generated-sources文件夹中的java文件。为了将这些文件存储在pom.xml文件中,我使用了下面的插件
<!-- For Code Generation -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<id>add-source-for-demoapp</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
<schemaIncludes>
<include>myschema.xsd</include>
</schemaIncludes>
<generateDirectory>target/generated-sources/xjc/workflow</generateDirectory>
<generatePackage>com.websystique.xml.workflow</generatePackage>
<!-- For including equals,hashcode and toString methods in generated code -->
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.9.4</version>
</plugin>
</plugins>
<args>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
<arg>-XtoString</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>现在,这个插件生成的java文件很少,为了访问这些文件,我在pom.xml中使用了下面的插件
<!-- For Adding Generated code directory as source folder -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated-sources/xjc/workflow/com.websystique.xml.workflow</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>我尝试了几种方法从目标文件夹中读取这些文件,如下所示。但是什么都不起作用。

除了上面两个插件外,我还在使用spring-boot-maven-plugin sonar-maven-plugin maven-surefire-plugin
发布于 2020-03-12 15:21:35
https://www.benchresources.net/jaxb-a-xml-parsing-technique/
生成文件后,在eclipse中的类路径下添加生成的/java/source文件夹。
https://stackoverflow.com/questions/60448794
复制相似问题