zoukankan      html  css  js  c++  java
  • Spring系列之——spring security

    1 搭建springboot


    2 配置pom依赖(springboot版本为2.1.3)

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

    3 写一个controller类


    4 SpringBootApplication中增加注解ComponentScan,并启动


    5 启动测试 http://localhost:8080/index

    5.1 开启验证(默认生效),需要输入用户名和密码

      springsecurity默认用户名为user,密码为运行日志中“Using generated security password”,如果需要支持其他用户需要重写抽象类WebSecurityConfigurerAdapter中的configure方法。

    5.2 关闭验证

      在启动类中排除SecurityAutoConfiguration

    package com.gbm.myspringboot;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
    import org.springframework.context.annotation.ComponentScan;
    
    @SpringBootApplication(exclude = SecurityAutoConfiguration.class)
    @ComponentScan(basePackages = {"com.gbm.controller"})
    public class MyspingbootApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(MyspingbootApplication.class, args);
        }
    }
    View Code

  • 相关阅读:
    linux commands ---2 ,学习vim编辑器如何使用的方法。
    $stateParams 详解
    ipa 打包遇到的坑
    原生和jQuery的ajax用法
    ios 的 desciption
    ios上线流程
    android 上线流程
    cordova 常用插件
    iframe
    cordova 强制竖屏
  • 原文地址:https://www.cnblogs.com/guobm/p/10409780.html
Copyright © 2011-2022 走看看