Error creating entityManagerFactory due to error tying to scan

后端 未结 6 1657
旧巷少年郎
旧巷少年郎 2020-12-30 05:37

I am following http://spring.io/guides/tutorials/data/3 ; I am not sure what I did wrong, but I keep on getting exceptions that I don\'t understand. I tried searching for q

相关标签:
6条回答
  • 2020-12-30 05:46

    First, get the version of javassist that works with Java 8:

    <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.18.2-GA</version> </dependency>

    If you use maven, exclude all others javassist dependencies:

    `<exclusions>
         <exclusion>
            <artifactId>javassist</artifactId>
            <groupId>org.javassist</groupId>
         </exclusion>
     </exclusions>`
    
    0 讨论(0)
  • 2020-12-30 05:47

    I had similar issue. My problem was that I had another dependency (in my case jboss weld) that used different version of javassist. Excluding did not help.

        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-se</artifactId>
            <version>1.0.1-Final</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>javassist</artifactId>
                    <groupId>org.javassist</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    

    So, above exclusion does not work. I had to find a workaround for jboss weld.

    0 讨论(0)
  • 2020-12-30 05:49

    The error:

    invalid constant type: 18
    

    Indicates that you have built the Jars with Java 8, but are attempting to run the application in a lower version.

    From what I have seen elsewhere, you probably need to switch to a newer version of javassist (which is raising the error), as the version you are using is not compatible with Java 8.

    0 讨论(0)
  • 2020-12-30 05:55

    If you use 3.6.10-Final you need exclude javassist (without org. prefix)

        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>3.6.10.Final</version>
                <scope>compile</scope>
                <exclusions>
                    <exclusion>
                        <artifactId>javassist</artifactId>
                        <groupId>javassist</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
           <!-- javassist with fixed https://issues.jboss.org/browse/JASSIST-174 -->
           <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.18.2-GA</version>
            </dependency>
    
    0 讨论(0)
  • 2020-12-30 05:56

    I had the same problem while migrating one of my projects to Java 8. Fixed it by updating the hibernate-entitymanager artifact version from 4.2.0.Final to 4.3.8.Final.

    0 讨论(0)
  • 2020-12-30 06:03

    You do not need to provide beans for EntityManagerFactory and EntityManager. Just provide a bean LocalContainerEntityManagerFactoryBean

    0 讨论(0)
提交回复
热议问题