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

Mou*_*una 2 reverse-engineering hibernate-tools maven

我想使用自定义的ReverseEgineeringStrategy. hibernate-tools我使用eclipse 插件成功地做到了这一点。但我想用hibernate3-maven-plugin它来做到这一点。我搜索了很多例子,但我发现的例子都不适合我。

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

Mou*_*una 5

我试过hibernate3-maven-plugin3.0版本

<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>3.0</version>
Run Code Online (Sandbox Code Playgroud)

不幸的是,我遇到了错误,并且没有成功地使其工作(异常消息也没有给我太大帮助)。

所以我尝试了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>
Run Code Online (Sandbox Code Playgroud)