KingerZha 2017-01-16 14:23 采纳率: 100%
浏览 1408
已采纳

maven 反向生成实体项目问题

想在eclipse里面弄一个maven的反向生成实体工程,配置好之后运行一直不生成实体,运行过程也不报错,运行命令使用的:hibernate3:hbm2java ,配置文件如下:

pom.xml

 <?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>AAAAA</groupId>
        <artifactId>AAAAA</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <groupId>AAAAA_PO</groupId>
    <artifactId>AAAAA_PO</artifactId>
    <name>AAAAA_PO</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
    </dependencies>

    <build>
        <finalName>AAAAA_PO</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>

                <dependencies>
                    <!-- mysql链接驱动,如果是Oracle的就换成Oracle的驱动 <dependency> <groupId>mysql</groupId> 
                        <artifactId>mysql-connector-java</artifactId> <version>5.1.25</version> </dependency> -->
                    <!-- oracle 链接驱动 -->
                    <dependency>
                        <groupId>com.oracle</groupId>
                        <artifactId>ojdbc6</artifactId>
                        <version>11.2.0.1.0</version>
                    </dependency>
                    <dependency>
                        <groupId>cglib</groupId>
                        <artifactId>cglib</artifactId>
                        <version>2.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>ejb3-persistence</artifactId>
                        <version>3.3.2.Beta1</version>
                    </dependency>
                </dependencies>

                <!-- 运行命令: mvn hibernate3:hbm2java hibernate3:hbm2hbmxml -->
                <configuration>
                    <components>
                        <!-- 映射文件夹 项目目录下运行命令:mvn hibernate3:hbm2hbmxml -->
                        <component>
                            <name>hbm2hbmxml</name>
                            <implementation>jdbcconfiguration</implementation>
                            <outputDirectory>src/main/java/</outputDirectory>
                        </component>
                        <!-- 实体类 项目目录下运行命令:mvn hibernate3:hbm2java -->
                        <component>
                            <name>hbm2java</name>
                            <outputDirectory>src/main/java/</outputDirectory>
                            <implementation>jdbcconfiguration</implementation>
                        </component>
                    </components>

                    <componentProperties>
                        <!-- 生成指定表名的实体类和映射文件(不配置则生成所有的数据表) -->
                        <revengfile>src/main/resources/reveng/hibernate.reveng.xml</revengfile>
                        <!-- hibernate总配置文件,注意是链接数据库的信息 --> 
                        <configurationfile>src/main/resources/reveng/hibernate.cfg.xml</configurationfile>
                        <!-- 输出的包名 -->
                        <packagename>org</packagename> 
                        <!-- true为注解实体类方式,只需要生成java类即可,false为映射文件和非注解java实体类,结合 -->
                        <ejb3>true</ejb3>
                    </componentProperties>

                    <!-- 1、如果你要生成注解方式的 java文件,就运行 mvn hibernate3:hbm2java 2、如果你要生成 hbm.xml 
                        配合 java 的形式就先把 pom 里面 <ejb3>false</ejb3> 弄成false 然后分别运行 mvn hibernate3:hbm2hbmxml 
                        和 mvn hibernate3:hbm2java -->

                </configuration>

            </plugin>
        </plugins>
    </build>
</project>

hibernate.cfg.xml

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
        <property name="hibernate.connection.password">fj_inms</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@127.0.0.1:1521:testOrac</property>
        <property name="hibernate.connection.username">fj_inms</property>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
    </session-factory>
</hibernate-configuration>

hibernate.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="sys_organization"/>

</hibernate-reverse-engineering>

运行配置

 hibernate3:hbm2java

运行控制台打印

 [INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building AAAAA_PO 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> hibernate3-maven-plugin:2.2:hbm2java (default-cli) > process-resources @ AAAAA_PO >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ AAAAA_PO ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] <<< hibernate3-maven-plugin:2.2:hbm2java (default-cli) < process-resources @ AAAAA_PO <<<
[INFO] 
[INFO] --- hibernate3-maven-plugin:2.2:hbm2java (default-cli) @ AAAAA_PO ---
[INFO] using jdbcconfiguration task.
[INFO] Hibernate 3.3.1.GA
[INFO] hibernate.properties not found
[INFO] Bytecode provider name : javassist
[INFO] using JDK 1.4 java.sql.Timestamp handling
[INFO] Configuration XML file loaded: file:/E:/work/workspace_mars/AAAAA/AAAAA_PO/src/main/resources/reveng/hibernate.cfg.xml
[INFO] configuring from url: file:/E:/work/workspace_mars/AAAAA/AAAAA_PO/src/main/resources/reveng/hibernate.cfg.xml
[INFO] Configured SessionFactory: null
[INFO] No hibernate properties file loaded.
[INFO] Override file: E:\work\workspace_mars\AAAAA\AAAAA_PO\src\main\resources\reveng\hibernate.reveng.xml
[INFO] Using Hibernate built-in connection pool (not for production use!)
[INFO] Hibernate connection pool size: 20
[INFO] autocommit mode: false
[INFO] using driver: oracle.jdbc.OracleDriver at URL: jdbc:oracle:thin:@127.0.0.1:1521:testOrac
[INFO] connection properties: {user=fj_inms, password=****}
[INFO] RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[INFO] JDBC driver: Oracle JDBC driver, version: 11.2.0.1.0
[INFO] Using dialect: org.hibernate.dialect.Oracle10gDialect
[INFO] Using default transaction strategy (direct JDBC transactions)
[INFO] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[INFO] Automatic flush during beforeCompletion(): disabled
[INFO] Automatic session close at end of transaction: disabled
[INFO] JDBC batch size: 15
[INFO] JDBC batch updates for versioned data: disabled
[INFO] Scrollable result sets: enabled
[INFO] JDBC3 getGeneratedKeys(): disabled
[INFO] Connection release mode: auto
[INFO] Default batch fetch size: 1
[INFO] Generate SQL with comments: disabled
[INFO] Order SQL updates by primary key: disabled
[INFO] Order SQL inserts for batching: disabled
[INFO] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[INFO] Using ASTQueryTranslatorFactory
[INFO] Query language substitutions: {}
[INFO] JPA-QL strict compliance: disabled
[INFO] Second-level cache: enabled
[INFO] Query cache: disabled
[INFO] Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
[INFO] Optimize cache for minimal puts: disabled
[INFO] Structured second-level cache entries: disabled
[INFO] Statistics: disabled
[INFO] Deleted entity synthetic identifier rollback: disabled
[INFO] Default entity-mode: pojo
[INFO] Named query checking : enabled
[INFO] cleaning up connection pool: jdbc:oracle:thin:@127.0.0.1:1521:testOrac
[INFO] Hibernate Tools 3.2.2.GA
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.482 s
[INFO] Finished at: 2017-01-16T22:12:45+08:00
[INFO] Final Memory: 18M/246M
[INFO] ------------------------------------------------------------------------
[INFO] cleaning up connection pool: jdbc:oracle:thin:@127.0.0.1:1521:testOrac
  • 写回答

2条回答 默认 最新

  • KingerZha 2017-01-17 08:04
    关注

    解决:
    注意问题:
    1、hibernate.cfg.xml配置文件中,schema使用大写,否则会出现不识别问题,如:
    FJ_INMS

    2、如果做单个表的反向生成,配置hibernate.reveng.xml文件时,表名需要大写,否则不识别

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含
  • ¥15 麒麟V10桌面版SP1如何配置bonding