在最新 spring-security-oauth2-2.0.6.RELEASE.jar 中找不到 TokenServicesUserApprovalHandler

TokenServicesUserApprovalHandler not found in latest spring-security-oauth2-2.0.6.RELEASE.jar

<bean id="userApprovalHandler" class="org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler">
  <property name="tokenServices" ref="tokenServices" />
</bean>

我的 spring-security.xml 中的以下代码与 spring-security-oauth2-1.0.1.RELEASE.jar 一起工作,但是当我将它升级到 spring-security-oauth2-2.0.6.RELEASE.jar 上述文件即 "org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler" 未找到。

我这样做是因为在之前的 jar 中,由于 Spring 4.1.X

,杰克逊存在一些冲突
17:14:53,679 WARN [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.oauth2.provider.token.DefaultTokenServices
com.aricent.ans.controller.um.UserController.tokenServices; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenServices' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Cannot
resolve reference to bean 'clientDetails' while setting bean property 'clientDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientDetails' defined in ServletContext resource
[/WEB-INF/spring-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.oauth2.provider.JdbcClientDetailsService]: Constructor
threw exception; nested exception is java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper

您使用的 Spring OAuth2 版本发生了变化。试试这个:

<bean id="userApprovalHandler" class="org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler">
    <property name="tokenStore" ref="tokenStore"/>
</bean>