0
点赞
收藏
分享

微信扫一扫

SpringBoot persistenceExceptionTranslationPostProcessor solution

哈哈我是你爹呀 2022-01-09 阅读 40

当自定义的类名是Environment 时,springboot 启动失败。

异常如下:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'persistenceExceptionTranslationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'persistenceExceptionTranslationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.env.Environment' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

原因:

springframework 自带core.env 包内已有Environment interface, springframework 同类名优先解析内置Environment 接口

解决方案:

将自定义类名替换成别的即可

举报

相关推荐

0 条评论