侧边栏壁纸
博主头像
landery博主等级

行李箱里装不下我想去的远方

  • 累计撰写 42 篇文章
  • 累计创建 24 个标签
  • 累计收到 6 条评论

目 录CONTENT

文章目录

Spring_boot JPA报错

landery
2022-06-20 / 0 评论 / 1 点赞 / 93 阅读 / 740 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-06-20,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

报错记录如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationRepository': Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$138/2041264753.getObject(Unknown Source)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:878)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at me.zhengjie.AppRun.main(AppRun.java:51)
Caused by: java.lang.IncompatibleClassChangeError: null
	at org.springframework.data.jpa.util.JpaMetamodel.lambda$isSingleIdAttribute$4(JpaMetamodel.java:94)
	at org.springframework.data.jpa.util.JpaMetamodel$$Lambda$794/1573457383.test(Unknown Source)
	at java.util.Optional.filter(Optional.java:178)
	at org.springframework.data.jpa.util.JpaMetamodel.isSingleIdAttribute(JpaMetamodel.java:94)
	at org.springframework.data.jpa.mapping.JpaPersistentPropertyImpl.lambda$new$2(JpaPersistentPropertyImpl.java:110)
	at org.springframework.data.jpa.mapping.JpaPersistentPropertyImpl$$Lambda$784/1404574293.get(Unknown Source)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:212)
	at org.springframework.data.util.Lazy.get(Lazy.java:94)
	at org.springframework.data.jpa.mapping.JpaPersistentPropertyImpl.isIdProperty(JpaPersistentPropertyImpl.java:141)
	at org.springframework.data.jpa.mapping.JpaPersistentEntityImpl.returnPropertyIfBetterIdPropertyCandidateOrNull(JpaPersistentEntityImpl.java:72)
	at org.springframework.data.jpa.mapping.JpaPersistentEntityImpl.returnPropertyIfBetterIdPropertyCandidateOrNull(JpaPersistentEntityImpl.java:39)
	at org.springframework.data.mapping.model.BasicPersistentEntity.addPersistentProperty(BasicPersistentEntity.java:218)
	at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:538)
	at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:506)
	at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:705)
	at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:374)
	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:248)
	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:191)
	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:85)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$4(RepositoryFactoryBeanSupport.java:295)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport$$Lambda$730/1608433267.accept(Unknown Source)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:295)
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:121)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
	... 15 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:53660', transport: 'socket'

Process finished with exit code 1

网络上各种,有说jar包的问题的,也有说注解的问题等等。。

之前运行都没有问题,可能是我队友修改了pom.xml 引入了其他的模块,那个模块需要更高的jdk版本才能运行,但是这个报错,就很迷。之前报的是logServiceImpl,和logRepository不能实例化,也是 Caused by: java.lang.IncompatibleClassChangeError: null 这个错,不停的删除建的类,找bug,最后发现是jdk版本的问题。

解决方法:更换jdk版本,我从jdk1.8.0_20直接升级到jdk 11。

安装方法:https://www.runoob.com/java/java-environment-setup.html

建议下载压缩包的版本,这样可以方便引用,需要加入环境变量,也可以手动加入。

1

评论区