ldap配置后启动项目有问题

来源:5-2 LDAP 配置和多 AuthenticationProvider 共存

oldfishSOHO

2022-08-17

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘securityConfig’ defined in file [D:\code\java\idea\starter\target\classes\com\imooc\uaa\starter\config\SecurityConfig.class]: Unsatisfied dependency expressed through constructor parameter 4; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘LDAPUserRepo’ defined in com.imooc.uaa.starter.security.auth.ldap.LDAPUserRepo defined in @EnableLdapRepositories declared on LdapRepositoriesRegistrar.EnableLdapRepositoriesConfiguration: Cannot resolve reference to bean ‘ldapTemplate’ while setting bean property ‘ldapOperations’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘ldapTemplate’ defined in class path resource [org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘ldapTemplate’ parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ldapContextSource’ defined in class path resource [org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ldap.core.support.LdapContextSource]: Factory method ‘ldapContextSource’ threw exception; nested exception is java.lang.IllegalAccessError: class org.springframework.ldap.core.support.AbstractContextSource (in unnamed module @0x11438d26) cannot access class com.sun.jndi.ldap.LdapCtxFactory (in module java.naming) because module java.naming does not export com.sun.jndi.ldap to unnamed module @0x11438d26

请老师帮忙诊断下什么问题,启动报错
写回答

2回答

邦邦不挖坑

2024-04-12

我遇到了类似的问题。问题源自jdk版本:你需要使用jdk11才能顺利启动项目以及通过单元测试。使用jdk 17 或者别的版本会遇到模块未导出的问题。如果你使用的编辑器是idea,那么可以在file -> project structure中,切换project sdk为11版的某种jdk比如amazon corretto(这个下载的快)即可。

0
0

接灰的电子产品

2022-08-26

和git对比一下看看是不是缺失依赖

0
2
接灰的电子产品
spring boot 版本多少
2022-08-31
共2条回复

Spring Security+OAuth2 精讲,打造企业级认证与授权

一站式掌握主流安全框架与行业解决方案,从容应对各种安全难题。

1042 学习 · 316 问题

查看课程