SpringLDAP示例需要持久性吗?

SpringLDAP示例需要持久性吗?,spring,ldap,spring-boot,Spring,Ldap,Spring Boot,我不熟悉Spring和LDAP。我发现了一个很棒的例子,解释了如何快速开始使用spring boot和apacheds。我按照示例使用建议的Gradle配置。当我启动spring boot时,我收到以下错误 Error creating bean with name 'persistenceExceptionTranslationPostProcessor' defined in class path resource [org/springframework/boot/autoconfig

我不熟悉Spring和LDAP。我发现了一个很棒的例子,解释了如何快速开始使用spring boot和apacheds。我按照示例使用建议的Gradle配置。当我启动spring boot时,我收到以下错误


 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.

我不知道为什么Spring会要求持久性转换器,尽管通过搜索其他帖子,发现类路径中似乎有一个ORM(我没有加载ORM JAR,如果从gradle中删除Spring安全启动条目,则不会发生异常)这就是Spring寻找JPA实现和转换器的原因。其他人对链接中的示例有异议。谢谢

问题在于
spring-security ldap
spring-tx
有一个可传递的依赖关系,并且正在引入的版本是3.2.8.RELEASE。Spring Boot 1.2需要4.1.x。这在Maven中不会发生,因为它具有优越的依赖关系管理

您可以通过在
spring tx
上添加显式依赖项来解决此问题。没有必要指定一个版本,因为Spring Boot会为您解决这个问题。根据您在问题中链接到的示例,这将使您的依赖项如下所示:

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.springframework:spring-tx")
    compile("org.springframework.security:spring-security-ldap:3.2.4.RELEASE")
    compile("org.apache.directory.server:apacheds-server-jndi:1.5.5")
    testCompile("junit:junit")
}

类路径上可能有一个
spring tx
依赖项,它包含
PersistenceExceptionTranslationPostProcessor
类。哪个类触发了
PersistenceExceptionTranslator
的配置。您可以通过将
spring.dao.exceptiontranslation.enabled=false
添加到您的
application.properties
文件来禁用此功能。使用org.apache.camel:camel-spring与org.apache.camel:camel-core组合使用时也会遇到同样的问题,但此解决方案同样有效,谢谢!)