maven引入shiro jar包

maven引入jar包

<!-- shiro-all -->  
<dependency>
    <groupId>org.apache.shiro</groupId>
    <artifactId>shiro-all</artifactId>
    <version>1.2.3</version>
</dependency>
<properties>  
    <shiro.version>1.2.3</shiro.version>  
</properties>  
  
<!-- shiro -->  
<!-- shiro核心包 -->
<dependency>  
    <groupId>org.apache.shiro</groupId>  
    <artifactId>shiro-core</artifactId>  
    <version>${shiro.version}</version>  
</dependency>  
<!-- 添加shiro web支持 -->
<dependency>  
    <groupId>org.apache.shiro</groupId>  
    <artifactId>shiro-web</artifactId>  
    <version>${shiro.version}</version>  
</dependency>  
<!-- 添加shiro spring整合 -->
<dependency>  
    <groupId>org.apache.shiro</groupId>  
    <artifactId>shiro-spring</artifactId>  
    <version>${shiro.version}</version>  
</dependency> 

在spring配置文件中引入shiro配置文件
<import resource="applicationContext-shiro.xml"/>

    方式一:直接在spring的配置文件中import shiro的配置文件
web.xml中配置spring
    <!-- 配置spring容器的路径 -->
    <context-param> <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/spring-context-*.xml</param-value>
    </context-param>
    <!-- 对spring开始监听 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
方式二:直接在web.xml中配置shiro的配置文件
<!-- Spring ApplicationContext 配置文件的路径,可使用通配符,多个路径用,号分隔 此参数用于后面的Spring Context Loader -->
<context-param> <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:/applicationContext-shiro.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

    原文作者:没事遛弯
    原文地址: https://www.jianshu.com/p/c1154bbca79f
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞