SpringBoot结合Dobbo出现Error

如题目所属,这是我遇到的问题,以此记录一下,不说上异常:

1
2
3
4
5
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'persistenceExceptionTranslationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.class]: Initialization of bean failed;
nested exception is java.lang.IllegalStateException:
No persistence exception translators found in bean factory.
Cannot perform exception translation.

这个是在我写练习Demo时遇到的错误,经过反复的琢磨之后,才发现,是在引入Dubbo时,由Dubbo引入的Spring包与SpringBoot引入的Spring包发生了冲突,所以修改pom.xml文件,

1
2
3
4
5
6
7
8
9
10
11
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>

这样就可以去掉Dubbo包中的Spring包了。