01-spring boot 2.6.2 spring security 集成
更多关注:JeeGit 5.0 企业级快速开发平台
在spring boot 项目中引入 spring security 的模块org.springframework.boot spring-boot-starter-security
完整代码如下:
创建一个webcontroller 类,内置一个请求。4.0.0 com.godzt jeegit-meta 5.0.1-SNAPSHOT ../meta/pom.xml jeegit-basic jar jeegit basic https://www.jeegit.com jeegit basic for web application 2022-Now com.godzt jeegit-common ${project.parent.version} com.godzt jeegit-framework-basicinfo ${project.parent.version} org.springframework.boot spring-boot-starter-security org.springframework.boot spring-boot-maven-plugin org.apache.maven.plugins maven-surefire-plugin true taoist-info hailu Yao admin at jeegit.com Project lead +8 GodZT https://www.godzt.com
package com.godzt.jeegit.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value="")
public class HelloWorld {
@RequestMapping(value="")
public String demo()
{
return "hello world";
}
}
启动spring boot
控制台会打印 默认分配的用户名密码
Using generated security password: 055f1b98-32e9-4f64-ac52-595baa5ada2d
则 默认的用户名是 user 密码见 控制台
http://localhost:8080/login 登录地址
http://localhost:8080/ogout 退出地址
更多关注:JeeGit 5.0 企业级快速开发平台



