maven-jaxb2-plugin 不生成任何输出

发布于 2024-12-02 07:06:05 字数 2109 浏览 4 评论 0原文

我是 Maven 新手,正在尝试使用它从我的 XSD 生成 Java 类。

我的 xsd 文件位于 src/main/resources/xsd

在依赖项中我有这个,但我认为我不需要它,因为我使用的是 Java 1.6

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.0</version>
    </dependency>

在构建部分我有

    <build>
     <pluginManagement>
     ..
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
               <source>1.6</source>
               <target>1.6</target>
            </configuration>
        </plugin>
     ..
       <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <includeSchemas>
                                <includeSchema>**/test.xsd</includeSchema>
                            </includeSchemas>

                            <generatePackage>com.myproject.adapter.generated</generatePackage>
                            <bindingDirectory>src/main/binding</bindingDirectory>
                            <removeOldOutput>true</removeOldOutput>
                            <verbose>true</verbose>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

但是,当我运行它时,我什么也得不到。 我已经运行 mvncompile 和generate-sources,并使用 -e 和 -X 标志来查看输出,但目标似乎没有被调用。 有什么想法吗?

I'm new to Maven, and am trying to use it to generate the Java classes from my XSD.

My xsd file is in src/main/resources/xsd

In dependencies I have this, but I don't think I need it as I'm using Java 1.6

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.0</version>
    </dependency>

In the build section I have

    <build>
     <pluginManagement>
     ..
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
               <source>1.6</source>
               <target>1.6</target>
            </configuration>
        </plugin>
     ..
       <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <includeSchemas>
                                <includeSchema>**/test.xsd</includeSchema>
                            </includeSchemas>

                            <generatePackage>com.myproject.adapter.generated</generatePackage>
                            <bindingDirectory>src/main/binding</bindingDirectory>
                            <removeOldOutput>true</removeOldOutput>
                            <verbose>true</verbose>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

But, when I run it, I get nothing.
I've run mvn compile and generate-sources, with the -e and -X flags to have a look at the output, but it seems the target isn't getting invoked.
Any ideas ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明媚如初 2024-12-09 07:06:05

首先,您应该始终指定您正在使用的依赖项或插件的版本

<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>

,然后您必须在执行中提供以下条目

<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
  <include>test.xsd</include>
</schemaIncludes>

这是一个完整的定义,我已经包含了 jaxb2-basics 插件,因为您几乎总是想要它的功能。

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<executions>
  <execution>
    <id>jaxb-test</id>
    <phase>generate-sources</phase>
    <goals>
      <goal>generate</goal>
    </goals>
    <configuration>
      <forceRegenerate>true</forceRegenerate>
      <schemaDirectory>src/main/resources</schemaDirectory>
      <schemaIncludes>
        <include>test.xsd</include>
      </schemaIncludes>
    </configuration>
  </execution>
</executions>
<configuration>
  <extension>true</extension>
  <args>
    <arg>-XtoString</arg>
    <arg>-Xequals</arg>
    <arg>-XhashCode</arg>
    <arg>-Xcopyable</arg>
    <arg>-Xmergeable</arg>
  </args>
  <plugins>
    <plugin>
      <groupId>org.jvnet.jaxb2_commons</groupId>
      <artifactId>jaxb2-basics</artifactId>
      <version>0.6.0</version>
    </plugin>
  </plugins>
</configuration>
</plugin>

first off you should always specify which version of a dependency or plugin you are using

<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>

then you have to supply the following entries inside an execution

<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
  <include>test.xsd</include>
</schemaIncludes>

Here is a complete definition, I have included the jaxb2-basics plugin as you almost always want what it does.

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<executions>
  <execution>
    <id>jaxb-test</id>
    <phase>generate-sources</phase>
    <goals>
      <goal>generate</goal>
    </goals>
    <configuration>
      <forceRegenerate>true</forceRegenerate>
      <schemaDirectory>src/main/resources</schemaDirectory>
      <schemaIncludes>
        <include>test.xsd</include>
      </schemaIncludes>
    </configuration>
  </execution>
</executions>
<configuration>
  <extension>true</extension>
  <args>
    <arg>-XtoString</arg>
    <arg>-Xequals</arg>
    <arg>-XhashCode</arg>
    <arg>-Xcopyable</arg>
    <arg>-Xmergeable</arg>
  </args>
  <plugins>
    <plugin>
      <groupId>org.jvnet.jaxb2_commons</groupId>
      <artifactId>jaxb2-basics</artifactId>
      <version>0.6.0</version>
    </plugin>
  </plugins>
</configuration>
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文