如何在 JAXB2 maven 插件版本 2.4 中定义架构目录?
How do I define schema directory in JAXB2 maven plugin version 2.4?
我正在尝试在 pom.xml 中为我的架构定义目录。我一直收到一条错误消息 "Element schemaDirectory is not allowed here"。我猜这个版本不支持这个元素。那么如何在这个版本中定义我的架构目录呢?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
</configuration>
</plugin>
提前致谢!
这对旧版本有效,例如。 1.5:
<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>
<schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
对于版本 2.4,根据文档,不再有 schemaDirectory
标签 https://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.4/xjc-mojo.html
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
<sources>
<source>${project.basedir}src/main/resources</source>
</sources>
</configuration>
</plugin>
对于版本 2.5.0
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/${specify.xsd}</source>
</sources>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
然后运行mvn compile
我正在尝试在 pom.xml 中为我的架构定义目录。我一直收到一条错误消息 "Element schemaDirectory is not allowed here"。我猜这个版本不支持这个元素。那么如何在这个版本中定义我的架构目录呢?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
</configuration>
</plugin>
提前致谢!
这对旧版本有效,例如。 1.5:
<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>
<schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
对于版本 2.4,根据文档,不再有 schemaDirectory
标签 https://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.4/xjc-mojo.html
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
<sources>
<source>${project.basedir}src/main/resources</source>
</sources>
</configuration>
</plugin>
对于版本 2.5.0
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/${specify.xsd}</source>
</sources>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
然后运行mvn compile