Hibernate + Java 9 + javax.transaction.SystemException

前端 未结 2 1793
天命终不由人
天命终不由人 2021-01-03 03:33

I kind of have the same problem as: Hibernate, Java 9 and SystemException

I can follow the steps like this

    
        

        
2条回答
  •  醉梦人生
    2021-01-03 04:18

    Ok, So it takes a bit This is also for JDK 10, The annotation processing is for JPAModelGen support.

    Configure maven

    
    1.10
    jre10 
    1.10
    1.10
    10
    

    Then configure the compiler for JDK 10

    
                            org.apache.maven.plugins
                            maven-compiler-plugin
                            ${maven.compiler.version}
                            
                                10
                            
                            
                                
                                    org.ow2.asm
                                    asm
                                    6.2 
                                
                            
                        
    

    Then add the patch modules for java.xml.bind and java.transaction

    
                org.apache.maven.plugins
                maven-compiler-plugin
                ${maven.compiler.version}
                
                    compile
                
                
                    ${project.build.directory}/generated-sources/annotations
                    
                        
                            org.hibernate
                            hibernate-jpamodelgen
                            ${maven.hibernate.version}
                        
                        
                            javax.xml.bind
                            jaxb-api
                            ${jaxb.version}
                        
                    
                    
                        org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
                    
                    
                        -AaddGeneratedAnnotation=false
                        --patch-module
                        java.transaction=${settings.localRepository}/javax/transaction/javax.transaction-api/${javax.transaction.transactionapi}/javax.transaction-api-${javax.transaction.transactionapi}.jar
                        --patch-module
                        java.xml.bind=${settings.localRepository}/javax/xml/bind/jaxb-api/${jaxb.version}/jaxb-api-${jaxb.version}.jar
                    
                    
                        false
                        true
                    
                    true
                
                
                    
                        org.hibernate
                        hibernate-jpamodelgen
                        ${maven.hibernate.version}
                        true
                    
                    
                        javax.xml.bind
                        jaxb-api
                        ${jaxb.version}
                        jar
                    
                
            
    

    Properties are

    2.3.0
    1.3
    5.3.2.Final
    6.0.10.Final
    5.0.1.Final
    1.0.2.Final
    

    Dependencies on top that i included to make sure maven downloaded

    
         javax.transaction
         javax.transaction-api
         ${javax.transaction.transactionapi}
         jar
         provided
    
    
    
    
        org.hibernate
        hibernate-core
        ${maven.hibernate.version}
        jar
        
            
                jboss-transaction-api_1.2_spec
                org.jboss.spec.javax.transaction
            
            
                javax.activation-api
                javax.activation
            
        
    
    
        org.hibernate.validator
        hibernate-validator
        ${maven.hibernate.validator.version}
        jar
        
            
                javax.validation
                validation-api
            
        
    
    

    but wait, there's more...

    opens xx.xx.xx.entities to org.hibernate.orm.core;
    
    requires java.transaction;
    requires java.xml.bind;
    requires java.sql;
    requires java.activation;
    requires java.persistence;
    

    Then configure your runtime accordingly, eclipse and netbeans just add the vm args for the patch modules defined above.

    I'm using @args here just to go with the grain of JDK 9 and up, so it is strict moduled. JDK 11 (ea so far) all of it is required, except for patch module specifications which can be removed as 1.3 will solely declare the package

提交回复
热议问题