如何配置maven hbm2hbmxml和hbm2java在mvn clean install中一个接一个地运行 [英] How to configure maven hbm2hbmxml and hbm2java to run one after the other in mvn clean install

查看:113
本文介绍了如何配置maven hbm2hbmxml和hbm2java在mvn clean install中一个接一个地运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够调用mvn clean install并使用maven调用hibernate3:hbm2hbmxml来从数据库生成映射文件,然后调用hbm2java获取Java文件,然后使用maven编译新创建的Java文件。
有没有人曾经这样做过?

I need to be able to call mvn clean install and have maven call hibernate3:hbm2hbmxml to generate the mapping files from a database and after than call hbm2java to get the Java files and then have maven compile those newly created Java files. Has anyone done this before?

谢谢

Thanks

推荐答案

如果你想拥有你的模型java文件(由reveng获得)编译后,你不需要运行hbm2hbmxml。

If you want to have your model java files (obtained by reveng) compiled, you don't need to run hbm2hbmxml.

插件配置:



plugin configuration:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <components>
                    <component>
                        <name>hbm2java</name>
                        <outputDirectory>src/main/java</outputDirectory>
                        <implementation>jdbcconfiguration</implementation>
                    </component>
                </components>
                <componentProperties>
                    <revengfile>/src/main/resources/reveng/model.reveng.xml</revengfile>
                    <propertyfile>/src/main/resources/META-INF/hibernate.properties</propertyfile>
                    <jdk5>true</jdk5>
                    <ejb3>true</ejb3>
                </componentProperties>
            </configuration>
            <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>
    </plugins>
</build>



hibernate.properties:

hibernate.properties :

hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialect
hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.connection.url = jdbc:mysql://localhost:3306/YOUR_DB
hibernate.connection.username = yourUsrName
hibernate.connection.password= yourPwd
hibernate.default_schema = YOUR_DB

model.reveng.xml:

model.reveng.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
    <table-filter match-name=".*" package="your.package.here" />
</hibernate-reverse-engineering>

您可以使用以下命令:

you fire this with:

mvn clean hibernate3:hbm2java compile

如果你希望它被解雇:

if you want it to be fired just with:

mvn clean compile

在您的插件定义中添加executions标签

add the "executions" tag in your plugin definition

            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals><goal>hbm2java</goal></goals>
                </execution>
            </executions>

这篇关于如何配置maven hbm2hbmxml和hbm2java在mvn clean install中一个接一个地运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆