How to configure maven hbm2hbmxml and hbm2java to run one after the other in mvn clean install

前端 未结 6 1381
一向
一向 2020-12-05 12:37

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 J

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 13:02

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

    plugin configuration:

    
        
            
                org.codehaus.mojo
                hibernate3-maven-plugin
                2.2
                
                    
                        
                            hbm2java
                            src/main/java
                            jdbcconfiguration
                        
                    
                    
                        /src/main/resources/reveng/model.reveng.xml
                        /src/main/resources/META-INF/hibernate.properties
                        true
                        true
                    
                
                
                    
                        mysql
                        mysql-connector-java
                        5.0.8
                    
                    
                        cglib
                        cglib-nodep
                        2.1_3
                    
                             
            
        
    
    

    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 :

    
    
    
        
    
    

    you fire this with:

    mvn clean hibernate3:hbm2java compile
    

    if you want it to be fired just with:

    mvn clean compile
    

    add the "executions" tag in your plugin definition

                
                    
                        compile
                        hbm2java
                    
                
    

提交回复
热议问题