说明一下,这个问题没解决,记录一下坑而已。。。
开始:
ssm项目+shiro
配置了定时任务如下:
<bean name="Job" class="XXX.controller.Job"/>
<bean id="job" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 执行的类 -->
<property name="targetObject">
<ref bean="Job"/>
</property>
<!-- 类中的方法 -->
<property name="targetMethod">
<value>getData</value>
</property>
</bean>
想要在定时任务getData()里去获取当前登录信息,所以:
User user=(User) SecurityUtils.getSubject().getPrincipal();
但是报错:
Caused by: org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.