请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

ldap配置后启动项目有问题

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

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

正在回答 回答被采纳积分+3

2回答

邦邦不挖坑 2024-04-12 23:19:01

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

0 回复 有任何疑惑可以回复我~
接灰的电子产品 2022-08-26 23:29:39

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

0 回复 有任何疑惑可以回复我~
  • 提问者 oldfishSOHO #1
    老师代码重写了一边,依然报上面这个问题,发现引用了这三个依赖<!-- LDAP 依赖开始 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-ldap</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.ldap</groupId>
                <artifactId>spring-ldap-core</artifactId>
            </dependency>
            <dependency>
                <groupId>com.unboundid</groupId>
                <artifactId>unboundid-ldapsdk</artifactId>
            </dependency>
            <!-- LDAP 依赖结束 --> 启动项目就报错
    回复 有任何疑惑可以回复我~ 2022-08-29 20:57:01
  • spring boot 版本多少
    回复 有任何疑惑可以回复我~ 2022-08-31 17:55:29
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信