定制逆向工程策略的逆向工程



我想做逆向工程(从我的数据库生成java类)与自定义的ReverseEgineeringStrategy。我成功地做到了这一点,使用hibernate-tools插件为eclipse。但我想用hibernate3-maven-plugin来做这个。我找了很多例子,但我找到的例子都不适合我。

如果有人知道我们该怎么做,我很感谢他的帮助。

我尝试了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>

最新更新