我正在尝试使用带有maven的ant任务生成hbm文件,但是它遇到了与classpath相关的问题。 (我这样做是为了将项目从ant迁移到maven,并且不想在第一步中改变hibernate的工作方式)。如果有人知道更好的方法来处理这个问题,那也会有所帮助。我的pom.xml看起来像
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>xdoclet</groupId>
<artifactId>xdoclet-hibernate-module</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>xjavadoc</groupId>
<artifactId>xjavadoc</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>xdoclet</groupId>
<artifactId>xdoclet-xdoclet-module</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.xdoclet</groupId>
<artifactId>xdoclet</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>20040616</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase> generate-sources</phase>
<configuration>
<target name="generate-hibernate" unless="hibernatedoclet.unnecessary">
<echo level="info">generating hibernate files</echo>
<taskdef name="hibernatedoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask"
classpathref="maven.plugin.classpath" />
<hibernatedoclet destdir="${project.build.directory}"
force="ture" verbose="true">
<fileset id="hbm" dir="${basedir}/src/main/java">
<include name="**/model/*.java" />
</fileset>
<hibernate version="3.0" />
</hibernatedoclet>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
我得到的例外是
Can't create a hibernate element under hibernatedoclet. Make sure the jar file containing the corresponding subtask class is on the classpath specified in the <taskdef> that defined {2}.
at xdoclet.DocletTask.createDynamicElement(DocletTask.java:343)
at org.apache.tools.ant.IntrospectionHelper.createDynamicElement(IntrospectionHelper.java:57
at org.apache.tools.ant.IntrospectionHelper.getNestedCreator(IntrospectionHelper.java:542)
at org.apache.tools.ant.IntrospectionHelper.getElementCreator(IntrospectionHelper.java:637)
at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:552)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:349)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:201)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:270)
答案 0 :(得分:1)
正如错误所说
无法在hibernatedoclet
下创建 hibernate 元素
我猜您需要将hibernate
添加到您的maven ant插件依赖项中。