Java Can';在SpringLDAP中不能进行身份验证

Java Can';在SpringLDAP中不能进行身份验证,java,spring,authentication,active-directory,spring-ldap,Java,Spring,Authentication,Active Directory,Spring Ldap,我将win server 2003与AD一起使用,并希望通过Spring LDAP进行连接。 当我尝试连接到http://localhost:8090/: 2017-05-19 22:48:46.768 ERROR 18868 --- [nio-8090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path

我将win server 2003与AD一起使用,并希望通过Spring LDAP进行连接。 当我尝试连接到
http://localhost:8090/

2017-05-19 22:48:46.768 ERROR 18868 --- [nio-8090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

java.lang.NullPointerException: null
    at hello.ldap.client.LdapClient.authenticate(LdapClient.java:26) ~[classes/:na]
    at hello.HelloController.index(HelloController.java:13) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
<...>
应用程序属性

server.port = 8090
ldap.partitionSuffix=dc=GRSU,dc=local
ldap.partition=GRSU
ldap.principal=cn=Jack Wood,cn=users
ldap.password=1234
ldap.port=389
ldap.url=ldap://192.168.56.101
起点 应用程序

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}
HelloController

package hello;

import hello.ldap.client.LdapClient;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
public class HelloController {

    @RequestMapping("/")
    public String index() {
        LdapClient ldapClient = new LdapClient();
        ldapClient.authenticate("Jack Wood", "1234");
        return "Greetings from Spring Boot!";
    }

}
广告结构

应用程序结构

据我所知,
contextSource
中的问题。我该怎么修理


非常感谢您的帮助。

您尚未启动spring应用程序。这是spring的起点,没有初始化任何东西都不会工作。 您必须在主方法中添加以下内容:

SpringApplication.run(Application.class, args);
并添加以下注释(如果您使用的是springboot):


我个人不相信baeldung是一个有效的教程网站。他们的做法往往有点粗略。这是我自己的意见。@kkflf您能为SpringLDAP提供哪些教程?谢谢您的评论。我试图修复它,但错误仍然存在。更新了主题,请看。你应该看这个教程:也许你可以帮忙?我明天会看。
package hello;

import hello.ldap.client.LdapClient;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
public class HelloController {

    @RequestMapping("/")
    public String index() {
        LdapClient ldapClient = new LdapClient();
        ldapClient.authenticate("Jack Wood", "1234");
        return "Greetings from Spring Boot!";
    }

}
SpringApplication.run(Application.class, args);
@SpringBootApplication