shiro权限注解无效

写了一个service,使用了权限注解和springMVC的注解,结果无效:

@Service
public class ShiroService {
    @RequiresRoles({"admin"})
    public void testMethod(){
        System.out.println("testMethod,time:"+new Date());
    }
}

这样写的话,  @RequiresRoles({"admin"})注解没有起作用。

将@Service去掉,改为在applicationContext.xml中配置:

 <bean id="shiroService" class="com.atguigu.shiro.service.ShiroService"></bean>

这样就ok了。

ps:同时,也不要将事务的注解写在service上面,可以写在controller上面。

发布了241 篇原创文章 · 获赞 94 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/weixin_41060905/article/details/100177963