使用自定义ReverseEgineeringStrategy进行逆向工程

时间:2014-05-13 15:27:42

标签: maven reverse-engineering hibernate-tools

我想使用自定义ReverseEgineeringStrategy进行逆向工程(从我的数据库生成java类)。我成功地使用hibernate-tools插件进行了eclipse。 但我想用hibernate3-maven-plugin来做这件事。我搜索了很多例子,但我找到的两个例子都没有。

如果有人知道我们如何做到这一点,我感谢他的帮助。

1 个答案:

答案 0 :(得分:2)

我尝试了hibernate3-maven-plugin 3.0版

<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>3.0</version>

不幸的是我遇到了错误而且没有成功使它工作(异常消息对我来说也没有帮助)。

所以我尝试了2.2版,它运行得很完美,我的pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>hbm2java</id>
                    <phase>install</phase>
                    <goals>
                        <goal>hbm2java</goal>
                    </goals>
                    <inherited>false</inherited>
                    <configuration>
                        <components>
                            <component>
                                <name>hbm2java</name>
                                <implementation>jdbcconfiguration</implementation>
                                <outputDirectory>target/generatedClasses</outputDirectory>
                            </component>
                        </components>
                        <componentProperties>
                            <jdk5>true</jdk5>
                            <ejb3>false</ejb3>
                            <revengfile>${basedir}\hibernate.reveng.xml</revengfile>
                            <reversestrategy>com.it.mybatis.MyReverseEngineeringStrategy</reversestrategy>
                            <propertyfile>${basedir}\database.properties</propertyfile>
                        </componentProperties>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc14</artifactId>
                    <version>10.2.0.2.0</version>
                </dependency>
                <dependency>
                    <groupId>cglib</groupId>
                    <artifactId>cglib-nodep</artifactId>
                    <version>2.1_3</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>


<dependencies>
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.2.5</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-tools</artifactId>
        <version>4.0.0-CR1</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.2.0</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.4</version>
    </dependency>
</dependencies>