解决:Initialization of bean failed; nested exception is java.lang.AbstractMethodError

环境

Spring Data Jpa + Hibernate

使用版本

hibernate
<hibernate.version>5.2.10.Finalhibernate.version>

Spring Data Jpa
<dependency>
  <groupId>org.springframework.datagroupId>
  <artifactId>spring-data-jpaartifactId>
  <version>2.0.2.RELEASEversion>
dependency>

错误发生点

@Repository
public interface UserDao extends JpaRepository<SYS_USER,String>,JpaSpecificationExecutor<SYS_USER>{

    /** * 根据用户名查找用户 * * @param username 用户名 * @return SYS_USER */
    SYS_USER findByUsername(String username);

}

控制台输出

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Initialization of bean failed; nested exception is java.lang.AbstractMethodError
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:522)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318)
    ... 74 more

原因

  1. 直接原因:不能实例化bean。
  2. 间接原因:版本冲突

解决

降低 spring-data-jpa 的版本

<version>1.11.9.RELEASEversion>

你可能感兴趣的:(常见问题解决)