Maven 与休眠工具
我正在尝试使用 Maven 生成我的类和 hibernate.cfg.xml。 好吧,我的项目中有一些类依赖于生成的 java 文件,所以我可能必须在项目清理时执行这个过程?我不知道如何配置它才能工作,所以这是一个问题。 嗯,我有一个没问题的database.properties 文件和我修改过的很多hbm.xml 文件。现在我想从 hbm.xml 文件和database.properties 文件生成hibernate.cfg.xml 和所有java 文件。 我当前的 Maven 条目如下所示:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<jdk5>true</jdk5>
<ejb3>true</ejb3>
<propertyfile>src/main/resources/database.properties</propertyfile>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>
</dependencies>
</plugin>
有人能帮我解决这个问题吗?我真的不知道该怎么做才能让这件事发挥作用。
I am trying to generate my classes and the hibernate.cfg.xml with maven.
Well i have classes in my project which depend on the generated java files so i will probably have to execute this process on project cleaning or so? I don't know how to configure this to work, so this is one question.
Well i have a database.properties file which is ok and a lot of hbm.xml files which i have modified. Now i want to generate the hibernate.cfg.xml and all java files from the hbm.xml files and the database.properties file.
My current maven entry looks like this:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<jdk5>true</jdk5>
<ejb3>true</ejb3>
<propertyfile>src/main/resources/database.properties</propertyfile>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>
</dependencies>
</plugin>
Could anyone help me with this? I really don't know what to do, to get this thing working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案是使用我自己编写的插件。
您可以在这里找到它: http://uploaded.to/file/j3j7b652
示例用法:
如果您有有任何问题,尽管问。配置属性均已记录。
Well my solution is using my selfwritten plugin.
Here you can find it: http://uploaded.to/file/j3j7b652
Sample usage:
If you have any questions, ask. The configuration properties are all documented.