我已经把这个问题搁置了一段时间,现在已经无处可去了。这就是我的security-context.xml中的内容。这将成为一个servlet。
<security:http auto-config="true">
<security:intercept-url pattern="/"
access="IS_AUTHENTICATED_REMEMBERED" />
<security:intercept-url pattern="/login.html"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:form-login login-page="/login.html"
authentication-failure-url="/loginFailed.html" default-target-url="" />
<security:anonymous />
<security:logout />
</security:http>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider
ref="ldapAuthProvider" />
</security:authentication-manager>
<beans:bean id="ldapAuthProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<beans:constructor-arg>
<beans:bean
class="org.springframework.security.ldap.authentication.BindAuthenticator">
<beans:constructor-arg ref="contextSource" />
<beans:property name="userSearch" ref="userSearch">
</beans:property>
</beans:bean>
</beans:constructor-arg>
<beans:constructor-arg>
<beans:bean id="authoritiesPopulator"
class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
<beans:constructor-arg ref="contextSource" />
<beans:constructor-arg value="" />
<beans:property name="groupRoleAttribute" value="cn" />
<beans:property name="searchSubtree" value="true" />
<beans:property name="rolePrefix" value="ROLE_" />
<beans:property name="convertToUpperCase" value="true" />
</beans:bean>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<beans:constructor-arg
value="thepathtomyLDAPdatabase" />
<beans:property name="userDn"
value="theuserpathforLDAP" />
<beans:property name="password" value="mypassword" />
</beans:bean>
<beans:bean id="userSearch"
class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<beans:constructor-arg index="0" value="CN=Users" />
<beans:constructor-arg index="1"
value="(sAMAccountName={0})" />
<beans:constructor-arg index="2" ref="contextSource" />
<beans:property name="searchSubtree" value="true" />
</beans:bean>
我一直收到以下错误:
nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/IncorrectResultSizeDataAccessException
有人可以告诉我我做错了什么吗?感谢。
答案 0 :(得分:4)
您需要确保在类路径上有spring-tx。如果您使用的是构建工具,可以通过查看类似search.maven.org的内容来确定其配置,以解释配置的外观。例如,如果您使用的是Spring 3.2.0.RELEASE和Maven,则需要确保在pom.xml中包含以下内容:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
请注意,确保Spring依赖项版本匹配(即组org.springframework的工件应匹配)至关重要,因此如果您不在其他地方使用Spring 3.2.0.RELEASE,则需要确保更改版本号以匹配其他Spring依赖项。