使用shiro进行权限控制的时候,启动抛出异常;
使用shiro进行粗粒度的权限控制,基于Filter进行权限控制,URL
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property user found for type Role! Did you mean 'users','users'?
因为caused by直接指向的是Repository接口,所以一针见血,只贴出DAO类的代码
package cn.itcast.bos.dao.system;
import java.util.List;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.jpa.repository.JpaRepository;
import cn.itcast.bos.domain.system.Role;
public interface RoleRepository extends JpaRepository<Role,Integer> {
@Query("from Role r inner join fetch r.users u where u.id = ?")
List<Role> findByUser(Integer id);
}
applicationContext.xml的代码如下(其中有几个冗余的名称空间,不会影响整体功能):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- 安全管理器 -->
<property name="securityManager" ref="securityManager"></property>
<!-- 未认证,跳转页面 -->
<property name="loginUrl" value="/login.html"></property>
<!-- 登陆后跳转的页面 -->
<property name="successUrl" value="/index.html"></property>
<!-- 没有权限跳转的页面 -->
<property name="unauthorizedUrl" value="/unauthorized.html"></property>
<!-- shiro URL控制过滤器规则 -->
<property name="filterChainDefinitions">
<value>
/login.html* = anon
/user_login.action* = anon
/validatecode.jsp* = anon
/css/** = anon
/js/** = anon
/images/** = anon
/services/** = anon
/pages/base/courier.html* = perms[courier.list]
/pages/base/area.html* = roles[base]
/** = authc
</value>
</property>
</bean>
<!-- 配置安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="bosRealm"></property>
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor">
</bean>
</beans>
如果还有需要,烦请各位大佬提出.在线等,急??