0

您好,我正在使用 maven2-xdoclet2-plugin 生成休眠映射

xdoclet 的配置与此类似:

<plugin>
    <groupId>org.codehaus.xdoclet</groupId>
    <artifactId>maven2-xdoclet2-plugin</artifactId>
    <version>2.0.7</version>
    <executions>
        <execution>
           <id>xdoclet</id>
           <phase>generate-sources</phase>
           <goals>
             <goal>xdoclet</goal>
           </goals>
        </execution>
    </executions>
    (... dependencies ...)
    <configuration>
        <configs>
          <config>
            <components>
              <component>
                <classname>org.xdoclet.plugin.hibernate.HibernateMappingPlugin</classname>
                <params>
                  <version>3.0</version>
                </params>
              </component>
            </components>
            <params>
              <destdir>${project.build.directory}/classes</destdir>
            </params>
           </config>
          </configs>
       </configuration>

当我跑

mvn clean generate-resources

它得到以下内容:

tree -L 2 target/classes/
target/classes/
|-- com
|   `-- company
|       `-- (the mappings generated)
`-- generated-resources
    `-- xdoclet
        `-- com
            `-- company
                `-- (the mappings generated)

所以我要避免的是在 jar 文件中包含“生成的资源”目录。

我怎样才能做到这一点?我没有太多运气做了一些谷歌搜索。

4

2 回答 2

0

您将映射文件打包到 JAR 文件中,因为映射文件生成到错误的输出目录。您配置了:

<destdir>${project.build.directory}/classes</destdir>

因此映射文件将在target/classes/用于构建输出 JAR 文件的文件夹中生成。尝试其他一些目录,例如:

<destdir>${project.build.directory}/generated</destdir>
于 2010-12-04T06:40:30.343 回答
0

我终于从 maven2-xdoclet2-plugin 移动到 xdoclet-maven-plugin 并且它按预期工作(我在休眠映射生成方面也遇到了一些问题)。

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xdoclet-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>xdoclet</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>xdoclet</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <tasks>
                    <hibernatedoclet
                        destdir="${project.build.outputDirectory}"
                        mergeDir="${project.basedir}/src/main/resources/hibernate">
                        <fileset dir="${project.basedir}/src/main/java"
                            includes="**/domain/**/*.java" />
                        <hibernate version="3.0" />
                    </hibernatedoclet>
                </tasks>
            </configuration>
        </plugin>
于 2010-12-05T19:52:50.613 回答