首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >maven-jaxb2-plugin没有生成任何输出

maven-jaxb2-plugin没有生成任何输出
EN

Stack Overflow用户
提问于 2011-08-31 00:48:53
回答 1查看 12.9K关注 0票数 1

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

我的xsd文件在src/main/resources/xsd中

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

代码语言:javascript
复制
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.0</version>
    </dependency>

在构建部分中,我有

代码语言:javascript
复制
    <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>

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-31 01:07:25

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

代码语言:javascript
复制
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>

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

代码语言:javascript
复制
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
  <include>test.xsd</include>
</schemaIncludes>

这里有一个完整的定义,我已经包含了jaxb2-basics插件,因为你几乎总是想要它做什么。

代码语言:javascript
复制
<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>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7246829

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档