SSM-Shiro整合配置文件

shiro与SSM整合之授权和注解式开发 文章目录1、shiro授权角色、权限权限表设计图:ShiroUserMapper:ShiroUserMapper.xml:MyRealm:2、Shiro的注解式开发常用注解介绍:ShiroUserController:在springmvc-servlet.xml添加:jsp中添加:测试: 1、shiro授权角色、权限 权限表设计图: ShiroUserMapper: Set<String&... 阅读详情

  我在简书也发布了一份,喜欢黑色背景的同学可以看一下

  暑假学习了SSH以及SSM框架的内容,开学几个星期也陆陆续续看了一下Shiro以及SpringSecuity对用户权限的管理方法。

  • 虽然Shiro并不像SpringSecuiity一样功能强大,但它对于新手比较友好,容易上手。
  • 对比于SpringSecuity,开发一个轻量级的网站速度更快,所需的功能也基本上够用。
  • 另外它独立性比较强,可以整合其他开源框架,而SpringSecuity依赖于Spring环境
    用一下随笔来记录一下自己配置文件,方便日后查看

1、文件目录
SSM-Shiro结构.png

SSM-Shiro结构2.png


2、配置文件

  • porm.xml
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>shiro_day2</artifactId>
    <groupId>shiro</groupId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>shiro_day2 Maven Webapp</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <shiro.version>1.4.1</shiro.version>
        <spring.version>5.0.2.RELEASE</spring.version>
        <aspectj.version>1.6.8</aspectj.version>
        <junit.version>4.12</junit.version>
        <slf4j.version>1.6.6</slf4j.version>
        <log4j.version>1.2.12</log4j.version>
        <mysql.version>8.0.15</mysql.version>
        <mybatis.version>3.4.5</mybatis.version>
        <mybatis-spring.version>1.3.0</mybatis-spring.version>
        <c3p0.version>0.9.1.2</c3p0.version>
        <pagehelper.version>5.1.10</pagehelper.version>
        <servlet.version>2.5</servlet.version>
        <jsp.version>2.2</jsp.version>
        <jstl.version>1.2</jstl.version>
        <commons-fileupload.version>1.3.1</commons-fileupload.version>
        <commons-io.version>2.4</commons-io.version>
        <fastjson.version>1.2.47</fastjson.version>
        <jackson.version>2.9.6</jackson.version>

    </properties>

    <dependencies>
        <!--shiro-->
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>${shiro.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>${shiro.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-cas</artifactId>
            <version>${shiro.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>${shiro.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-ehcache</artifactId>
            <version>${shiro.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-quartz</artifactId>
            <version>1.4.0</version>
        </dependency>


        <!--spring-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
        <!--test-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <!--servlet-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency> <!-- log start -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
        </dependency> <!-- log end -->

        <!--mybatis-->
        <!--mysql-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>${mybatis.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>${mybatis-spring.version}</version>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>${c3p0.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>${pagehelper.version}</version>
        </dependency>

        <!-- 文件上传组件 -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>${commons-fileupload.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>
        <!--<dependency>
          <groupId>org.json</groupId>
          <artifactId>json</artifactId>
          <version>20170516</version>
        </dependency>-->
        <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>





    </dependencies>

    <build>
        <finalName>shiro_day2</finalName>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.0.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

  • web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0"
         metadata-complete="false">
  <display-name>Archetype Created Web Application</display-name>

  <!--配置 Spring-->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml,
                  classpath:springShiro2.xml
    </param-value>
  </context-param>

  <!--shiro过滤器-->
  <filter>
    <filter-name>shiroFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
      <param-name>targetFilterLifecycle</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>shiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <!--中文过滤器-->
  <filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <!--监听器-->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!--配置 DispatcherServlet-->
  <servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springMvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>


  <welcome-file-list>
    <!--<welcome-file>/WEB-INF/index.jsp</welcome-file>-->
    <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>

</web-app>


  • 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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!--包扫描-->
    <context:component-scan base-package="cn.T4">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
        <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
    </context:component-scan>

<!--    <context:component-scan base-package="cn.T4.mapper"></context:component-scan>
    <context:component-scan base-package="cn.T4.service"></context:component-scan>
    <context:component-scan base-package="cn.T4.shiro"></context:component-scan>-->

    <!--引入 jdbc.properties-->
    <context:property-placeholder location="classpath:other/jdbc.properties"></context:property-placeholder>

    <!--配置DataSource-->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driver}"></property>
        <property name="jdbcUrl" value="${jdbc.url}"></property>
        <property name="user" value="${jdbc.username}"></property>
        <property name="password" value="${jdbc.password}"></property>

        <!-- c3p0连接池私有属性 -->
        <property name="maxPoolSize" value="30"/>
        <property name="minPoolSize" value="10"/>
        <!-- 关闭连接后不自动commit -->
        <property name="autoCommitOnClose" value="false"/>
        <!-- 获取连接超时时间 -->
        <property name="checkoutTimeout" value="10000"/>
        <!-- 当获取连接失败后重新连接的次数 -->
        <property name="acquireRetryAttempts" value="2" />
    </bean>


    <!--配置mybatis-->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <!--配置别名-->
        <property name="configLocation" value="classpath:mabatis_config.xml"/>
        <!--配置mapper地址-->
        <property name="mapperLocations" value="classpath:mappers/*.xml"/>
    </bean>

    <!--启动mybatis 接口代理-->
    <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="cn.T4.mapper"/>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
    </bean>

    <!--事务-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!--配置事务通知-->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">

        <tx:attributes>
            <tx:method name="insert*" propagation="REQUIRED"/>
            <tx:method name="update*" propagation="REQUIRED"/>
            <tx:method name="upd*" propagation="REQUIRED"/>
            <tx:method name="edit*" propagation="REQUIRED"/>
            <tx:method name="save*" propagation="REQUIRED"/>
            <tx:method name="add*" propagation="REQUIRED"/>
            <tx:method name="new*" propagation="REQUIRED"/>
            <tx:method name="set*" propagation="REQUIRED"/>
            <tx:method name="remove*" propagation="REQUIRED"/>
            <tx:method name="delete*" propagation="REQUIRED"/>
            <tx:method name="del*" propagation="REQUIRED"/>
            <tx:method name="change*" propagation="REQUIRED"/>
            <tx:method name="check*" propagation="REQUIRED"/>
            <tx:method name="get*" propagation="REQUIRED" read-only="true"/>
            <tx:method name="search*" propagation="REQUIRED" read-only="true"/>
            <tx:method name="find*" propagation="REQUIRED" read-only="true"/>
            <tx:method name="load*" propagation="REQUIRED" read-only="true"/>
            <tx:method name="*" propagation="REQUIRED" read-only="true"/>
        </tx:attributes>
    </tx:advice>

    <!--配置事务切面-->
    <aop:config>
        <aop:pointcut id="serviceOperation" expression="(execution(* cn.T4.service.*Impl.*(..)))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation"/>
    </aop:config>

</beans>

  • springMvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <!--包扫描-->
    <context:component-scan base-package="cn.T4.controller" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
    </context:component-scan>

<!--    <context:component-scan base-package="cn.T4.controller"/>-->

    <!--转发-->
    <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <!--放行静态资源-->
    <mvc:resources location="/static/css/" mapping="/static/css/**" ></mvc:resources>
    <mvc:resources location="/static/js/" mapping="/static/js/**" ></mvc:resources>
    <mvc:resources location="/static/image/" mapping="/static/image/**" ></mvc:resources>
    <!--<mvc:Resources mapping="/static/**" location="/static/"></mvc:Resources>-->

    <!--开启注解-->
    <mvc:annotation-driven></mvc:annotation-driven>
</beans>

  • mybatis_confing.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
    <typeAliases>
        <package name="cn.T4.domain"/>
    </typeAliases>

</configuration>

  • springShiro.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">



    <!-- =========================================================
         Shiro Core Components - Not Spring Specific
         ========================================================= -->


    <!--缓存框架
           ehcache Let's use some enterprise caching support for better performance.  You can replace this with any enterprise
       caching framework implementation that you like (Terracotta+Ehcache, Coherence, GigaSpaces, etc -->
    <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        <!-- Set a net.sf.ehcache.CacheManager instance here if you already have one.  If not, a new one
             will be creaed with a default config:
             <property name="cacheManager" ref="ehCacheManager"/> -->
        <!-- If you don't have a pre-built net.sf.ehcache.CacheManager instance to inject, but you want
             a specific Ehcache configuration to be used, specify that here.  If you don't, a default
             will be used.:
        <property name="cacheManagerConfigFile" value="classpath:some/path/to/ehcache.xml"/> -->
        <property name="cacheManagerConfigFile" value="classpath:ehcache.xml"/>
    </bean>


    <!-- 配置 securityManager
          Shiro's main business-tier object for web-enabled applications
       (use DefaultSecurityManager instead when there is no web environment)-->
    <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
        <!--单例模式 Single realm app.  If you have multiple realms, use the 'realms' property instead. -->
        <!--<property name="sessionMode" value="native"/>-->
        <!--配置缓存-->
        <property name="cacheManager" ref="cacheManager"/>
        <!--自定义realm -->
        <property name="realm" ref="userRealm"/>
        <!--配置sessionManage-->
        <property name="sessionManager" ref="sessionManager"/>
        <!--配置rememberMe-->
        <property name="rememberMeManager" ref="rememberMeManager"/>
    </bean>


    <!-- 凭证匹配器 -->
    <bean id="credentialsMatcher" class="cn.T4.credentials.MyHashedCredentialsMatcher">
        <!-- 使用Spring构造器注入cacheManager  自己实现一个来Map 来存储 信息-->
        <constructor-arg ref="cacheManager"/>
        <!-- 指定散列算法名称 -->
        <property name="hashAlgorithmName" value="md5"/>
        <!-- 指定散列迭代的次数 -->
        <property name="hashIterations" value="2"/>
        <!-- 是否储存散列后的密码为16进制,需要和生成密码时的一样,默认是base64 -->
        <property name="storedCredentialsHexEncoded" value="true"/>
    </bean>

    <!-- 配置自己的UserRealm
            Used by the SecurityManager to access security data (users, roles, etc).
         Many other realm implementations can be used too (PropertiesRealm,
         LdapRealm, etc. -->
    <bean id="userRealm" class="cn.T4.shiro.UserRealm">
        <!--是否启用缓存-->
        <property name="credentialsMatcher" ref="credentialsMatcher"></property>
        <property name="cachingEnabled" value="true"></property>
        <!--分别启用 认证 和 授权 缓存-->
        <property name="authenticationCachingEnabled" value="true"></property>
        <property name="authenticationCacheName" value="authenticationCache"></property>

        <property name="authorizationCachingEnabled" value="true"></property>
        <property name="authorizationCacheName" value="authorizationCache"></property>
    </bean>

    <!--rememberMe-->
    <bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
        <constructor-arg value="rememberMe"/>
        <property name="maxAge" value="2592000"></property>
        <property name="httpOnly" value="true"></property>
    </bean>
    <bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
        <!-- cipherKey是加密rememberMe Cookie的密匙,默认AES算法 -->
        <property name="cipherKey" value="#{T(org.apache.shiro.codec.Base64).decode('4AvVhmFLUs0KTA3Kprsdag==')}"/>
        <property name="cookie" ref="rememberMeCookie"></property>
    </bean>
    <!--&lt;!&ndash; 基于Form表单的身份验证过滤器 &ndash;&gt;
    <bean id="formAuthenticationFilter" class="org.apache.shiro.web.filter.authc.FormAuthenticationFilter">
        &lt;!&ndash; 这两个字段,username和password要和表单中定义的username和password字段名称相同,可以更改,但是表单和XML要对应 &ndash;&gt;
        <property name="usernameParam" value="username"/>
        <property name="passwordParam" value="password"/>
        <property name="loginUrl" value="/login.jsp"/>
        &lt;!&ndash; rememberMeParam是rememberMe请求参数名,请求参数是boolean类型,true表示记住我 &ndash;&gt;
        <property name="rememberMeParam" value="rememberMe"/>
    </bean>-->

    <!--sessionCookie-->
    <bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
        <constructor-arg value="sid"/>
        <property name="httpOnly" value="true"></property>
        <property name="maxAge" value="-1"></property>
    </bean>
    <!--生成sessionIdCookie-->
    <bean id="sessionIdGenerator" class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator"></bean>
    <!--SessionDao-->
    <bean id="sessionDAO" class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
        <property name="activeSessionsCacheName" value="shiro-activeSessionCache"></property>
        <property name="sessionIdGenerator" ref="sessionIdGenerator"></property>
    </bean>
    <!--会话验证调度器-->
    <bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.quartz.QuartzSessionValidationScheduler">
        <property name="sessionValidationInterval" value="1800000"></property>
        <property name="sessionManager" ref="sessionManager"></property>
    </bean>
    <!--会话管理器-->
    <bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
        <!--配置持久化Dao-->
        <property name="sessionDAO" ref="sessionDAO"></property>
        <!--全局会话过期时间-->
        <property name="globalSessionTimeout" value="1800000"></property>
        <!--是否自动删除无效对话-->
        <property name="deleteInvalidSessions" value="true"/>
        <!--配置会话验证-->
        <property name="sessionValidationSchedulerEnabled" value="true"/>
        <property name="sessionValidationScheduler" ref="sessionValidationScheduler"></property>
        <!--配置sessionCookie-->
        <property name="sessionIdCookieEnabled" value="true"/>
        <property name="sessionIdCookie" ref="sessionIdCookie"/>
    </bean>



    <!-- =========================================================
         Shiro Spring-specific integration 特有整合
         ========================================================= -->
    <!-- Post processor that automatically invokes init() and destroy() methods
         for Spring-configured Shiro objects so you don't have to
         1) specify an init-method and destroy-method attributes for every bean
            definition and
         2) even know which Shiro objects require these methods to be
            called. -->

    <!--声明周期-->
    <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

    <!-- 启动 Shiro Annotations
            Enable Shiro Annotations for Spring-configured beans.  Only run after
         the lifecycleBeanProcessor has run: -->
    <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
          depends-on="lifecycleBeanPostProcessor"/>
    <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
        <property name="securityManager" ref="securityManager"/>
    </bean>


    <!-- 远程调用安全
            Secure Spring remoting:  Ensure any Spring Remoting method invocations can be associated
         with a Subject for security checks. -->
    <bean id="secureRemoteInvocationExecutor" class="org.apache.shiro.spring.remoting.SecureRemoteInvocationExecutor">
        <property name="securityManager" ref="securityManager"/>
    </bean>

    <!-- 定义shiroFilter bean id 和web.xml相同
            Define the Shiro Filter here (as a FactoryBean) instead of directly in web.xml -
         web.xml uses the DelegatingFilterProxy to access this bean.  This allows us
         to wire things with more control as well utilize nice Spring things such as
         PropertiesPlaceholderConfigurer and abstract beans or anything else we might need: -->
    <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
        <property name="securityManager" ref="securityManager"/>
        <!--未认证的访问的页面-->
        <property name="loginUrl" value="/login.jsp"/>
        <!--登录成功后访问的页面-->
        <property name="successUrl" value="/index.jsp"/>
        <!--未授权也能访问的页面-->
        <property name="unauthorizedUrl" value="/unauthorized.jsp"/>
        <!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean
             defined will be automatically acquired and available via its beanName in chain
             definitions, but you can perform overrides or parent/child consolidated configuration
             here if you like: -->
        <!-- <property name="filters">
            <util:map>
                <entry key="aName" value-ref="someFilterPojo"/>
            </util:map>
        </property> -->
        <property name="filterChainDefinitions">
            <value>
                <!--map key value
                    请求访问的URL资源 = 拦截器
                    ANT风格 ?任意一个字符   /* 任意内容 /** 任意目录内容

                    anno 匿名拦截器 (未认证情况下允许访问)
                    authc 认证拦截器 (认证成功下允许访问)
                    logout 认证过滤器
                    roles[角色名称] 角色过滤器

                    -->
                <!--/logout=logout 可以用-->
                <!--# everything else requires authentication:
                /index.jsp = authc-->


                /static/** = anon
                /js/** = anon
                /css/** = anon
                /image/** = anon
                /user/login=anon
                /index=anon
                /logout=logout

                /student.jsp=roles[stu]
                /teacher.jsp=roles[tea]
                /list.jsp=roles[tea,stu]

                /**=authc
            </value>
        </property>

        <!--工厂注入 -->
        <!--<property name="filterChainDefinitionMap" ref="filterChainDefinitionMap"></property>-->
    </bean>

    <!--工厂注入 通过 数据库的 rescource 表 得到 data 放入 Map 中-->
    <!--工厂注入 构建bean-->
   <!-- <bean id="filterChainDefinitionMapBuilder" class="cn.T4.credentials.FilterChainDefinitionMapBuilder"></bean>
    <bean id="filterChainDefinitionMap" factory-bean="filterChainDefinitionMapBuilder" factory-method="builder"></bean>-->

</beans>

  • ehcache.xml
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
         updateCheck="false" name="shirocache">
    <diskStore path="java.io.tmpdir"/>

    <!--
     缓存配置
            name:缓存名称。
            maxElementsInMemory:缓存最大个数。
            eternal:对象是否永久有效,一但设置了,timeout将不起作用。
            timeToIdleSeconds:设置对象在失效前的允许闲置时间(单位:秒)。仅当eternal=false对象不是永久有效时使用,可选属性,默认值是0,也就是可闲置时间无穷大。
            timeToLiveSeconds:设置对象在失效前允许存活时间(单位:秒)。最大时间介于创建时间和失效时间之间。仅当eternal=false对象不是永久有效时使用,默认是0.,也就是对象存活时间无穷大。
            overflowToDisk:当内存中对象数量达到maxElementsInMemory时,Ehcache将会对象写到磁盘中。
            diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区。
            maxElementsOnDisk:硬盘最大缓存个数。
            diskPersistent:是否缓存虚拟机重启期数据 Whether the disk store persists between restarts of the Virtual Machine. The default value is false.
            diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒。
            memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)。
            clearOnFlush:内存数量最大时是否清除。
            maxBytesLocalHeap是用来限制缓存所能使用的堆内存的最大字节数的,其单位可以是K、M或G,不区分大小写。默认是0,表示不限制
            maxBytesLocalOffHeap是用来限制缓存所能使用的非堆内存的最大字节数,其单位也可以是K、M或G。默认是0,表示不限制。
            maxBytesLocalDisk是用来限制缓存所能使用的磁盘的最大字节数的,其单位可以是K、M或G。默认是0,表示不限制。只有在单机环境下才可以使用本地磁盘
            maxEntriesLocalHeap是用来限制当前缓存在堆内存上所能保存的最大元素数量的
     -->

    <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            overflowToDisk="true"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"/>



    <cache name="passwordRetryCache"
           maxElementsInMemory="2000"
           eternal="false"
           overflowToDisk="false"
           timeToIdleSeconds="300"
           timeToLiveSeconds="0" />



    <cache name="authenticationCache"
           maxElementsInMemory="2000"
           eternal="false"
           overflowToDisk="false"
           timeToIdleSeconds="300"
           timeToLiveSeconds="0" />



    <cache name="shiro-activeSessionCache"
           maxElementsInMemory="2000"
           eternal="false"
           overflowToDisk="false"
           timeToIdleSeconds="300"
           timeToLiveSeconds="0" />

</ehcache>

  • UserMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.T4.mapper.UserMapper">
    <resultMap id="userMap" type="cn.T4.domain.User">
        <id property="id" column="id"></id>
        <result column="username" property="username" jdbcType="VARCHAR"/>
        <result column="password" property="password" jdbcType="VARCHAR"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="SMALLINT"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
    </resultMap>
      .....
      .....
</mapper>
TBOX(Telematics Box)在智能网联汽车中的核心功能与应用场景解析 TBOX(Telematics Box)是智能网联汽车的“中枢神经”,基于Android或Linux操作系统,并通过CAN总线与车辆深度交互。它实现了远程控制、车辆状态监控、OTA升级及紧急呼叫(E-CALL)等核心功能,是提升用车安全、便利性与实现车辆持续进化的关键技术组件。 阅读详情

相关推荐

ContextCapture、EPS、CASS3D房地一体详细操作流程

还是房地一体的作业流程,这次我们整合了ContextCapture操作流程部分以及EPS和CASS3D三维采集绘制房屋及地形。结合房地一体项目全流程来分享新技术带来的便利。 第一步还是前期资料准备,这里不多赘述,可以参考之前的文章→ 房地一体工作浅谈(一)——资料准备 房地一体工作浅谈(二)——外业工作 关于外业及内业处理部分可参考我们之前的文章:无人机航测从外业作业到内业处理,我们有一整套实战教程!(精灵4RTK外业部分) 下面是我们整合的ContextCapture、EPS、CASS3D三个软件的操作.

qq_43173805的博客 1万+

Shiro

1 必须导入依赖 2 在shiroconfig.java文件中配置方言支持(就是将shrio的语法转为tymeleaf的语法) 3 在html中添加依赖 1 设置不同的登录状态显示不同的标签需要shiro的拦截器将该页面设置为未登录也可以访问,或者默认就是未登录可访问 2.获取当前登录的用户名 <shiro:principal/> 3/如果用户有某个角色就显示对应的字 <shiro:hasRole name="admin">超级管理员</

sharesb的博客 914

ANPC三电平拓扑:两种调制方式解析

ANPC结构是基于“I”型NPC结构(下面讲NPC如不特殊说明,均指的是“I”型结构NPC)发展出来的一种改进型。我们在讲NPC结构的时候会谈到他的一个缺点就是损耗分布不均匀,会导致温升不均衡,进而限制模块的功率输出能力。而ANPC结构由于多了两个开关管以及相应的两个中性点换流回路(如下图),可以更加灵活任意的配置开关管可以使损耗没有那么的不均衡,从而能一定程度上提高模块的输出功率。ANPC拓扑结构图以及增加的环流回路。

IOTBOT的博客 9508

【Shiro】Apache Shiro架构之实际运用(整合到Spring中)

写在前面:如题,这篇博文主要是总结一下如何将Shiro运用到实际项目中,本来准备将Shiro整到Spring中就行了,后来想想既然要整,就索性把SpringMVC和MyBatis也整进去吧,整个比较完整的,也能帮助更多的初学者。所以本文实际是将Shiro整到SSM中(基于maven)。 其实Shiro整合到Spring中并没有想象的那么困难,整到Spring中后,我们自定义的realm啊、se

2万+

腾讯游戏安全组件运行异常的全面解决方案

在使用腾讯游戏时,玩家可能会遭遇游戏安全组件运行异常的问题,这不仅影响游戏的正常启动,还可能在游戏过程中引发一系列问题。本文将详细介绍解决腾讯游戏安全组件运行异常的几种方法,帮助玩家重拾游戏乐趣。腾讯游戏安全组件运行异常是一个复杂的问题,可能涉及服务设置、游戏更新、系统环境优化以及硬件与驱动检查等多个方面。最后,希望本文能帮助玩家顺利解决腾讯游戏安全组件运行异常的问题,让玩家能够无忧无虑地享受游戏带来的乐趣。首先,我们需要从系统的服务管理入手,检查与游戏安全组件相关的服务是否正常运行。

nntxthml的博客 5820

CloudCompare

分割点云:选中要分割的点云文件–>Segment–>左键框出要分割的点或者区域–>Segment Out–>Comfirm Segmentation,原点云文件被分割成两个结构,选中分割出来的remaining,右键delete即可。qSRA (Surface of Revolution Analysis):计算一个点云和一个假定旋转平面之间的距离(旋转平面用2D轮廓定义),距离计算好后,用户可以创建一个偏差的2D图或者圆柱或圆锥的投影。②表现为同样的对象或者至少有同样的形状。

xiaoyaolangwj的博客 4709

【shiro】解决页面上使用shiro标签无效问题

场景: 今天在做页面shiro标签权限控制时,意外发现,所有都无效,检查数据库权限设置及对当前账号的授权,都没问题,而且在对应的 Realm 中 的 doGetAuthorizationInfo() 方法中断点,发现刷新页面,根本就不会进入当前鉴权方法中,经过排查,发现是 shiroConfig中忘记开启页面上使用 Shiro 标签,添加 ShiroDialect 方法后就可以了...

_修铁路的、的博客 5112

LAMMPS实操系列(四): 高熵合金FCC-CoCrCuFeNi的退火模拟

我们对FCC-CoCrCuFeNi的退火模拟思路主要是,首先将材料以均匀的速率用100 ps从300 K升温至1000 K,然后在1000 K的温度下平衡100 ps,随后以均匀的速率用100 ps从1000 K降温至300 K,随后通过共轭梯度下降法做静力学结构优化得到退火后的结构。由于FCC-CoCrCuFeNi高熵合金被认为是潜在的工程结构材料[1],接下来我们将对退火前后的结构进行压缩模拟,对比退火前后FCC-CoCrCuFeNi高熵合金的力学性能变化,敬请各位读者关注我们的更新。

Ceshigo_CD的博客 4839

shiro+thymeleaf 整合

SpringBoot中实现Shiro控制ThymeLeaf界面按钮级权限控制 移动开发 ## 需求简述 在业绩核算系统中,我们使用了SpringBoot作为项目的整体架构,使用ThymeLeaf作为前端界面框架,使用Shiro作为我们的权限控制框架,Shiro作为轻量级的权限框架,使用起来非常方便,但是在使用的过程中我发现,Shiro作为页面级的权限控制框架非常好用,它可以注入到Con...

贱气逼人的博客 2万+

用STM32F103单片机控制电调制动无刷电机

用电调控制无刷电机制作遥控飞艇 蓝牙控制 调控电调 无刷电机 用电调控制无刷电机制作遥控飞艇 代码区 mian.c #include "delay.h" #include "sys.h" #include "usart.h" #include "usart3.h" #include "timer.h" #include "led.h" #include "key.h" int main(v...

子非鱼 的博客 2万+

【2005】人工智能⭐

问题的解答来自于过去的经验而不是规则,这些经验是以案例方式存储的。但是当人们遇到一个新的问题的时候,一般先是回忆,从记忆中找到一个与新的问题相似的案例,然后把该案例的有关信息和知识复用到新问题的求解之中。1、若案例(case)不够充足,而有足够的规则(知识),试问如何构建一个包含有基于案例推理和基于规则推理的推理系统,以使推理效率提高而且总能求得问题的解。一般认为,CBR适合缺乏完备和健全的理论,但又可获取丰富经验的领域,而RBR则适合于对领域有充分的认识,能以完备和健全的形式表示领域理论的场合。

super_mochi1 283

shiro

shiro 概述: Apache Shiro是Java的一个安全框架,Shiro是一个强大的简单易用的Java安全框架,主要用来更便捷的认证、授权、加密、会话管理、与Web集成、缓存等 shiro不依赖于spring,shiro不仅可以实现web应用的权限管理,还可以实现c/s系统,分布式系统权限管理,可以单独使用。 shiro的整体类图: shiro包括了以下核心类: Authentication:身份认证/登录,验证用户是不是拥有相应的身份; Authorization:授权,即权限验证,验证某个已认

a416951514的博客 229

最小二乘(MLS)求点云法向量

MLS算法的基本思想是通过在点云的局部邻域内拟合一个光滑曲面,如平面或多项式曲面,以此来重建和处理点云数据。对于法向量估计,MLS通常在每个点的邻域内拟合局部平面,然后从该平面的法向量作为点的法向量。

twnkie的博客 745

ssm整合shiro,activiti配置文件

mybatis整合文件,只是插入了分页插件,可自行增加插件 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-con...

qianbanteng0945的博客 436

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SSM整合shiro框架相关配置文件

1.创建相关表 2.导入maven依赖    &lt;properties&gt;        &lt;java.version&gt;1.8&lt;/java.version&gt;        &lt;spring.version&gt;5.0.7.RELEASE&lt;/spring.version&gt;        &lt;aspectj.version&gt;1...

yfy的博客 663

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

在 SSM 框架整合 Shiro 的相关案例

SSM(三)Shiro使用详解shiro权限控制(一):shiro介绍以及整合SSM框架SpringMVC+Shiro整合配置文件详解 Shiro笔记(三)—-Shiro配置文件ini详解

HeatDeath的博客 1329

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Shiro学习(二):Web中整合Shiro

DelegatingFilterProxy 是 Spring Framework 提供的一个特殊的 Filter 实现类,用于将 Filter 的。目标 Filter Bean 名称,指定要委托的 Spring 容器中的 Filter Bean 的名称,如果不设。DelegatingFilterProxy 默认使用Filter 名称作为目标Bean 的名称,如Shiro与Web 整合时,可以使用Shiro自带的Relam,若自定义Relam,请参考上一篇中的CustRelam,这里不。

liang8999的博客 1312

从实例入手学习SSM与Shiro的整合流程

场景 从实例入手学习Shiro与Web的整合: https://blog.youkuaiyun.com/BADAO_LIUMANG_QIZHI/article/details/90140802 在此基础上,实现Shiro与SSM整合。 关于SSM的整合不做过多介绍,请参照: 第一个SSM整合的Maven入门级项目(超详细步骤) https://blog.youkuaiyun.com/BADAO_LIUMANG...

BADAO_LIUMANG_QIZHI的博客 379

ssm整合shiro 一体项目

介绍 在上上一篇文章中,我对shiro进行了初步的讲解。ssm与shiro的整合不像是springboot与springsecurity整合那样免去了很多步骤,ssm与shiro的整合与shiro非web的用法十分贴近。该文章将讲解ssm整合shiro一体项目(非前后分离)。 配置说明 在看如何配置之前,为了不显得突兀,推荐看一下我上一篇文章"ssm整合"。 红框为新添加的配置文件。 appl...

weixin_44363422的博客 516

SSM整合Shiro

[main] myRealm = CustomRealm securityManager.realms = $myRealm #定义凭证匹配器 credentialsMatcher = org.apache.shiro.authc.credential.HashedCredentialsMatcher #散列算法 credentialsMatcher.hashAlgorithmName = md5 #散列次数 credentialsMatcher.hashIterations = 1 myRealm.cr

qq_38975806的博客 393

SSM整合shiro

shiro中内置很多过滤器,而每个过滤都有相应的别名.(1)创建一个maven的web工程。企业中老项目还在使用ssm框架。(2)修改spring配置文件。(2)ssm整合到web工程。(1)引入shiro的依赖。修改controller层。修改web.xml文件。web.xml配置文件。spring配置文件。(3)整合shiro。...

m0_58212960的博客 144

ssm整合shiro实现权限

前言:开发后台怎么都会遇到权限这一块儿,谁都不例外。 第一步:导入jar包 commons-beanutils-1.8.3.jar commons-logging-1.1.1.jar log4j-1.2.17.jar shiro-all-1.3.2.jar shiro-core-1.2.3.jar shiro-spring-1.3.2.jar slf4j-api-1.7.5.j

pan_y95的博客 4294

SSM+Shiro+用户登录授权

SSM与整合Shiro进行整合实现用户登录验证及权限分配 在前面的学习过程中,已经学习了 Shiro的一些基本组件以及如何利用Shiro进行权限控制。下面学习用目前比较主流的SSM框架来整合Shiro框架,将我们前面学习的一些基本知识运用到实际项目之中。由于本人初学,内容可能比较粗浅,后期进行深入理解后会细化,SSM项目的搭建过程这里不再叙述,可查阅其他人教程学习,可能有时间也会进行回顾记录。 ...

编程小白 3117

SSM + jsp整合shiro

1.首先整合SSM框架,起码项目要能跑起来 以前整合好的ssm框架 springmvc-config.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:mvc="http://www.spr

qq_41501190的博客 448

SSM整合

  Spring和整合实际上最大的特点就是可以交由Spring实现shiro的管理控制,实际上这种整合才属于新一代的SSM开发框架整合(Spring+Shiro+MyBatis)。   SSH:Spring + Struts + Hibernate,但是后来Struts框架没落了;   SSM一代:Spring + SpringMVC + MyBatis,SpringMVC本来就属于Sprin...

weixin_30909575的博客 96

shiro+ssm

shiro+ssm 一、pom.xml配置文件 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.a...

weixin_38601197的博客 197
上一篇: Android Studio + Eclipse 实现类似微博主页功能APP
下一篇: Html+Css+JQuery实现简易英雄联盟官网
Mr丶LuoT4
博客等级 码龄9年 18粉丝 12原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值