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

har*_*028 5 java security spring spring-mvc spring-security

<bean id="userApprovalHandler" class="org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler">
  <property name="tokenServices" ref="tokenServices" />
</bean>
Run Code Online (Sandbox Code Playgroud)

我的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而在jackson方面存在一些冲突

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
Run Code Online (Sandbox Code Playgroud)

小智 7

这是您正在使用的Spring OAuth2版本的更改.试试这个:

<bean id="userApprovalHandler" class="org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler">
    <property name="tokenStore" ref="tokenStore"/>
</bean>
Run Code Online (Sandbox Code Playgroud)