SecurityContextHolder.getContext()。getAuthentication()在@Async方法中返回null

时间:2017-08-24 06:08:34

标签: spring spring-security

SecurityContextHolder.getContext().getAuthentication()当我在null方法中调用时返回@Async。试图使用SecurityContextHolder.MODE_INHERITABLETHREADLOCAL策略。但它不起作用

<bean
      class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
      <property name="targetClass" value="org.springframework.security.core.context.SecurityContextHolder" />
      <property name="targetMethod" value="setStrategyName" />
      <property name="arguments" value="MODE_INHERITABLETHREADLOCAL" />
  </bean>

在applicationContext-security.xml和applicationContext.xml中使用

0 个答案:

没有答案