欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringSecurity默認(rèn)登錄頁的使用示例教程

 更新時(shí)間:2023年12月05日 09:23:16   作者:宣布無人罪  
Spring 是非常流行和成功的 Java 應(yīng)用開發(fā)框架,Spring Security 正是 Spring 家族中的成員,Spring Security 基于 Spring 框架,提供了一套 Web 應(yīng)用安全性的完整解決方案,本文給大家介紹SpringSecurity的默認(rèn)登錄頁的使用教程,感興趣的朋友一起看看吧

SpringSecurity的默認(rèn)登錄頁的使用

01 前期準(zhǔn)備

引入依賴

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
		<!--mysql驅(qū)動(dòng)-->
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
		<!--模塊化插件配置類-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--mybatisplus依賴-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.1</version>
        </dependency>
		<!--spring-security依賴-->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

配置系統(tǒng)文件

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/(需要連接的數(shù)據(jù)庫)?userSSL=false;serverTimezone=Asia/Shanghai
    username: (賬號(hào))
    password: (密碼)
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher
mybatis-plus:
  config-locations: classpath:mapper/*.xml
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

配置掃描包

@SpringBootApplication
@MapperScan("com.example.demo.mapper")
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

02 編寫測試接口

測試類

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Category {
  @TableId
  private Long categoryId;
  private String categoryName;
  private String categoryPicture1;
  private String categoryPicture2;
}

測試用的控制層接口

@RestController
@RequestMapping("category")
public class CategoryController {
     @Autowired
     private ICategoryService iCategoryService;
    @GetMapping("all")
    public GetData selectAll(){
        List<Category> categories=iCategoryService.list();
        GetData getData = new GetData(200,"查詢成功",categories);
        return getData;
    }
    @GetMapping("byId")
    public GetData selectDetail(Long id){
        Category category=iCategoryService.getById(id);
        GetData getData = new GetData(200,"查詢成功",category);
        return getData;
    }
}

03 啟動(dòng)項(xiàng)目

啟動(dòng)之后,會(huì)自動(dòng)生成默認(rèn)密碼

在這里插入圖片描述

  • Using generated security password: 8d97e198-138c-4093-9a5c-ac83e2dda426
  • 這時(shí)候訪問接口被spring-security默認(rèn)攔截,必須登錄后才能訪問

在這里插入圖片描述

  • 默認(rèn)界面的賬號(hào)默認(rèn)user,密碼是Using generated security password隨機(jī)生成的 

到此這篇關(guān)于SpringSecurity的默認(rèn)登錄頁的使用的文章就介紹到這了,更多相關(guān)SpringSecurity默認(rèn)登錄頁內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • SpringBoot讀取properties中文亂碼解決方案

    SpringBoot讀取properties中文亂碼解決方案

    本文主要介紹了在Spring?Boot中讀取帶有中文字符串的application.properties文件時(shí)遇到亂碼問題的解決方案,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-12-12
  • Java飛行記錄器JFR功能實(shí)現(xiàn)過程圖解

    Java飛行記錄器JFR功能實(shí)現(xiàn)過程圖解

    這篇文章主要介紹了Java飛行記錄器JFR功能實(shí)現(xiàn)過程圖解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-05-05
  • Spring Cloud Feign文件傳輸?shù)氖纠a

    Spring Cloud Feign文件傳輸?shù)氖纠a

    微服務(wù)中通常使用 Feign 作為服務(wù)消費(fèi)者,那么如何使用 Feign 接口傳輸文件呢?這篇文章主要介紹了Spring Cloud Feign文件傳輸?shù)氖纠a,感興趣的小伙伴們可以參考一下
    2018-06-06
  • 一文掌握Spring中循環(huán)依賴與三級(jí)緩存

    一文掌握Spring中循環(huán)依賴與三級(jí)緩存

    這篇文章主要介紹了Spring中循環(huán)依賴與三級(jí)緩存,Spring通過三級(jí)緩存解決了循環(huán)依賴,其中一級(jí)緩存為單例池,二級(jí)緩存為早期曝光對(duì)象earlySingletonObjects,三級(jí)緩存為早期曝光對(duì)象工廠(singletonFactories),本文結(jié)合實(shí)例代碼介紹的非常詳細(xì),需要的朋友參考下吧
    2023-09-09
  • Java雙重MD5加密實(shí)現(xiàn)安全登錄

    Java雙重MD5加密實(shí)現(xiàn)安全登錄

    MD5對(duì)密碼進(jìn)行加密存儲(chǔ)是常見的一種加密方式,本文主要介紹了Java雙重MD5加密實(shí)現(xiàn)安全登錄,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • Springboot項(xiàng)目異常處理及返回結(jié)果統(tǒng)一

    Springboot項(xiàng)目異常處理及返回結(jié)果統(tǒng)一

    這篇文章主要介紹了Springboot項(xiàng)目異常處理及返回結(jié)果統(tǒng)一,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-08-08
  • Java實(shí)現(xiàn)后臺(tái)發(fā)送及接收json數(shù)據(jù)的方法示例

    Java實(shí)現(xiàn)后臺(tái)發(fā)送及接收json數(shù)據(jù)的方法示例

    這篇文章主要介紹了Java實(shí)現(xiàn)后臺(tái)發(fā)送及接收json數(shù)據(jù)的方法,結(jié)合實(shí)例形式分析了java針對(duì)json格式數(shù)據(jù)的傳輸與操作相關(guān)技巧,需要的朋友可以參考下
    2018-12-12
  • 詳解MyBatis resultType與resultMap中的幾種返回類型

    詳解MyBatis resultType與resultMap中的幾種返回類型

    本文主要介紹了MyBatis resultType與resultMap中的幾種返回類型,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • 解決Eclipse/STS中出現(xiàn)Resource is out of sync with the file system的異常問題

    解決Eclipse/STS中出現(xiàn)Resource is out of sync with the file system

    今天小編就為大家分享一篇關(guān)于解決Eclipse/STS中出現(xiàn)Resource is out of sync with the file system的異常問題,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2018-12-12
  • 利用Java連接Hadoop進(jìn)行編程

    利用Java連接Hadoop進(jìn)行編程

    這篇文章主要介紹了利用Java連接Hadoop進(jìn)行編程,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下
    2022-06-06

最新評(píng)論