简体   繁体   中英

Spring LDAP example requires persistence?

I am new to Spring and LDAP. I found an awesome example that explains how to quickly start with spring boot and apacheds. I followed the example by using the suggested Gradle configuration. The link . When I start spring boot I receive the following error...


 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.

I am not sure why Spring is asking for the persistence translator though from searching through other postings it appears there is an ORM within the classpath (I haven't loaded an ORM JAR and the exception does not occur if the spring security boot entry is removed from gradle) and this is why Spring is looking for a JPA implementation and the translator. Anyone else have issue with the example from the link. Thanks!

The problem is that spring-security-ldap has a transitive dependency on spring-tx and the version that's being pulled in is 3.2.8.RELEASE. Spring Boot 1.2 requires 4.1.x. This doesn't happen with Maven due to its superior dependency management.

You can fix the problem by adding an explicit dependency on spring-tx . There's no need to specify a version as Spring Boot will take care of this for you. Based on the example that you linked to in the question, this will leave your dependencies looking like this:

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")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM