Spring security Spring Security 3.1和正确的JAR

Spring security Spring Security 3.1和正确的JAR,spring-security,Spring Security,我正在使用Spring3.1,这是我第一次使用LDAP 这是我的*-security.xml: <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc

我正在使用Spring3.1,这是我第一次使用LDAP

这是我的*-security.xml:

<beans:beans xmlns="http://www.springframework.org/schema/security"
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.1.xsd">

  <http auto-config="true">
    <intercept-url pattern="/welcome*" access="ROLE_USER" />
    <form-login login-page="/login" default-target-url="/welcome"
      authentication-failure-url="/loginfailed" />
    <logout logout-success-url="/logout" />
  </http>

  <ldap-server url = "ldap://ldap-east.abc.acme.org:636/o=acme.org" />

    <authentication-manager>
      <ldap-authentication-provider user-dn-pattern="uid={0},ou=people"/>
    </authentication-manager>

</beans:beans>
我收到了这个错误信息:

org.springframework.context.ApplicationContextException:
找不到:org.springframework.ldap.core.support.BaseLdapPathContextSource。
如果您将LDAP与Spring Security一起使用, 请确保在应用程序中包含SpringLDAP jar文件; 嵌套异常为java.lang.ClassNotFoundException:
org.springframework.ldap.core.support.BaseLdapPathContextSource

因此,我在lib中添加了更多jar作为这组安全文件:

spring-ldap-core-1.3.1.RELEASE.jar
spring-ldap-core-tiger-1.3.1.RELEASE.jar
spring-security-ldap-3.1.0.RELEASE.jar
spring-security-config-3.1.0.RELEASE.jar
spring-security-core-3.1.0.RELEASE.jar
spring-security-taglibs-3.1.0.RELEASE.jar
spring-security-web-3.1.0.RELEASE.jar
这让我更深入地了解了更多的错误信息:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.filterChains': 
Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' 
while setting bean property 'sourceList' with key [0]; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': 
Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' 
while setting constructor argument with key [2]; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0':
Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' w
hile setting bean property 'authenticationManager'; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': 
Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' 
while setting constructor argument; nested exception is 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': 
FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.authenticationManager': 
Cannot resolve reference to bean 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0' 
while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0': 
Cannot create inner bean '(inner bean)' of type [org.springframework.security.ldap.authentication.BindAuthenticator] 
while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name '(inner bean)#17': Cannot resolve reference to bean 'org.springframework.security.securityContextSource' 
while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.securityContextSource': 
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [org.springframework.security.ldap.DefaultSpringSecurityContextSource]: 
Constructor threw exception; nested exception is java.lang.NoClassDefFoundE
我正在做很多事情,学习Maven在我的名单上,但我还没有做到。关于使用Spring3.1使用正确的混合jar进行基本LDAP身份验证,有什么建议吗


我试着加载整个Spring 3.1.1 dist、整个Spring LDAP 1.3.1 dist和整个Spring Security 3.1.0 dist。我已经准备好了一切。所以我不知道这是一个怎样的依赖性问题,FWIW。

spring-security-config
spring-security-taglibs
spring-security-ldap
这3个应该足够了,如果您使用maven或类似的工具,他们将提取其依赖项

如果没有,您需要遍历所有3个lib,并在类路径中复制它们的所有依赖项

检查此线程

正如ryan stewart所说:

Blockquote spring ldap未包含在基本spring 3.1发行版中。事实上,它的版本控制是完全独立的,目前的版本是1.3.1

您需要从下载额外的jar


所有这些都归功于org.springframework.ldap.core.support.BaseLdapPathContextSource位于spring security ldap jar中。可能不是jar问题,而是类路径问题。回顾一下你的类路径JDDSantaella,它会是一个怎样的类路径问题?提到的所有JAR都在我的war/WEB-INF/lib目录中。谢谢。我试着将整个Spring 3.1.1 dist、整个Spring LDAP 1.3.1 dist和整个Spring Security 3.1.0 dist加载到我的war/WEB-INF/lib中。我什么都有。所以我不知道这是一个怎样的依赖性问题,FWIW。就像我写的,我正在做大量的补习。Maven在我的名单上。不过我还没到。在不使用Maven的情况下找到这三个JAR的依赖项有什么建议吗?谢谢。我找到了这个依赖项列表。我会让每个人都知道它是否奏效:请参见上面的依赖关系图。你应该开始使用maven,这会让你更容易了解依赖关系。fmucar,这个图表是maven的一个很好的广告。哈哈:)它在我的清单上,今天之后,我可能会把它排在我需要学习的其他东西之前。
spring-security-config
spring-security-taglibs
spring-security-ldap