依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
spring.application.name=hello-security
curl访问,提示401 Unauthorized拒绝访问
$ curl -i http://localhost:8080/some/path
HTTP/1.1 401
...
浏览器访问http://localhost:8080/some/path,重定向到默认登录页面

And if you hit an endpoint with credentials (found in the console output) as follows:
如果您使用凭据(在控制台输出中找到)访问端点,如下所示:
$ curl -i -u user:8e557245-73e2-4286-969a-ff57fe326336 http://localhost:8080/some/path
HTTP/1.1 404
...
然后Spring boot将为请求提供服务,在这种情况下返回404 Not Found,因为/some/path不存在。

2171

被折叠的 条评论
为什么被折叠?



