zoukankan      html  css  js  c++  java
  • 引入redis

    Redis缓存

    引入starter

    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    

    配置properties

    #redis配置
    spring.redis.host=localhost
    #驼峰命名规则
    mybatis.configuration.map-underscore-to-camel-case=true

    Bean序列化:implements Serializable

     

    @EnableAsync:开启异步注解

    @Async:异步注解

    定时任务

    @EnableScheduling:开启定时任务

    @Scheduled(cron="")

     

    spring security

    引入模块

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    编写配置

    @EnableWebSecurity
    public class MySecurityConfig extends WebSecurityConfigurerAdapter {
    
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            //super.configure(http);
            http.authorizeRequests().mvcMatchers("/").permitAll()
                    .mvcMatchers("/level1").hasRole("VIP1")
                    .mvcMatchers("/level2").hasRole("VIP2")
                    .mvcMatchers("/level3").hasRole("VIP3");
            //自动配置登录
            http.formLogin();
    
            //自动配置注销
            http.logout();
            //记住我
            http.rememberMe();
        }
        
        //认证规则
    
        @Override
        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
            //super.configure(auth);
            auth.inMemoryAuthentication()
                    .withUser("zhangsan").password("123456").roles("VIP1","VIP2")
                    .and()
                    .withUser("lisi").password("123456").roles("VIP3","VIP2");
        }
    }
    //自动配置登录
            /**
             * loginPage("/userLogin")到自己的登录界面
             * 默认post形式的/login代表处理登录
             *  默认表单username和password
             *  .usernameParameter("user")定制名字
             *  .passwordParameter("pwd")
             *  一旦定制loginPage,loginPage的post请求就是登录
             */
            http.formLogin().usernameParameter("user").passwordParameter("pwd").loginPage("/userLogin");
    
            //自动配置注销
            http.logout();
            //记住我  rememberMeParameter与checkbox名字一样
            http.rememberMe().rememberMeParameter("remember");

    引入依赖

    <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->
    <dependency>
        <groupId>org.thymeleaf</groupId>
        <artifactId>thymeleaf</artifactId>
        <version>3.0.11.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4 -->
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        <version>3.0.2.RELEASE</version>
    </dependency>
  • 相关阅读:
    JS案例
    JS案例--Tab栏切换
    currentBackgroundImage:获取按钮背景图片
    笔记:UITextView内容垂直居中方法
    笔记:载入viewcontroller的几种方式
    沙盒文件的创建(简单举例)
    笔记:iOS随机数与随机数据集
    四种传值方法(通知、block、属性、NSUserDefaults)
    笔记:沙盒文件的拷贝
    笔记:iOS字符串的各种用法(字符串插入、字符串覆盖、字符串截取、分割字符串)(别人的代码直接复制过来的,我脸皮有点厚)
  • 原文地址:https://www.cnblogs.com/0710whh/p/12256642.html
Copyright © 2011-2022 走看看