Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister

错误描述:
spring boot 启动时报错
javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister

环境pox.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>admin-data</artifactId>
    <properties>
        <java.version>11</java.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <javax.persistence-api.version>2.2</javax.persistence-api.version>
        <javax.servlet-api.version>4.0.1</javax.servlet-api.version>
        <commons-lang3.version>3.8.1</commons-lang3.version>
        <disruptor.version>3.3.7</disruptor.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven-install-plugin.version>2.5.2</maven-install-plugin.version>
        <lombok.version>1.18.2</lombok.version>
        <redis-lettuce.version>4.5.0.Final</redis-lettuce.version>
        <commons-pool2.version>2.6.0</commons-pool2.version>
        <fastjson.version>1.2.51</fastjson.version>
        <druid.version>1.1.12</druid.version>
        <druid-spring-boot-starter.version>1.1.10</druid-spring-boot-starter.version>
        <log-slf4j.version>1.7.25</log-slf4j.version>
        <!-- mysql驱动版本号 -->
        <!--<mysql-driver.version>5.1.47</mysql-driver.version>-->
        <mysql-driver.version>8.0.13</mysql-driver.version>
        <!-- charset encding -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
    <dependencies>
        <!-- start: spring boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- spring-data-jpa -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- 数据库 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <!--<scope>runtime</scope>-->
            <version>${mysql-driver.version}</version>
        </dependency>
        <!-- spring-security 和 jwt -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.9.1</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-core -->
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${log-slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.54</version>
        </dependency>
    </dependencies>
</project>

foxwho.风
解决方法:增加依赖

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

解决问题的思路:
把springboot<artifactId>spring-boot-starter-parent</artifactId>版本升级到最新版2.1.1.RELEASE,可以解决报错问题。
但是 项目都是基于2.0.7.RELEASE 版本的,升级到最新版,其他模块都报错,所以只能在此基础上进行解决。

搜索了网络的各种方法,都没用,最后实在没有办法了。把内部依赖一个个升级试试看。
最后升级到此处javassist时才完美解决启动报错。

发布了377 篇原创文章 · 获赞 144 · 访问量 164万+
展开阅读全文

org.hibernate.MappingException问题?

08-28

八月 28, 2015 10:11:04 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.0.0.Final} 八月 28, 2015 10:11:04 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.20.Final} 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 八月 28, 2015 10:11:04 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: com/aliyun/house1848/hibernate/test/AdminInfo.hbm.xml 八月 28, 2015 10:11:04 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!) 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: false 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] at URL [jdbc:sqlserver://localhost:1433] 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=sa, password=****} 八月 28, 2015 10:11:05 下午 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect 八月 28, 2015 10:11:05 下午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 八月 28, 2015 10:11:05 下午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185) at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:389) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1799) at com.aliyun.house1848.hibernate.test.HibernateTest.main(HibernateTest.java:35) Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:138) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:188) at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:341) at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:506) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:146) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163) ... 4 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135) ... 13 more Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for registDate in class com.aliyun.house1848.hibernate.test.AdminInfo at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:316) at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310) at org.hibernate.mapping.Property.getGetter(Property.java:321) at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:444) at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:200) at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:82) ... 18 more Exception in thread "main" java.lang.NullPointerException at com.aliyun.house1848.hibernate.test.HibernateTest.main(HibernateTest.java:40) ![图片说明](https://img-ask.csdn.net/upload/201508/28/1440772766_259070.png) 而且javassit.jar包也已经导入了。 这是什么错误?怎么修改呢? 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览