【发布时间】:2021-07-09 01:20:39
【问题描述】:
我使用 Spring Initializr(https://start.spring.io)构建了一个新的 Spring Boot 项目。
我包括了很多东西,包括 Spring Security,因为我以后会想要它。
我有一个 @RestController 和一个 @GetMapping 方法。一切都很好。唯一的问题是当我点击 URL 时,我被定向到 Spring Security 登录表单(我在其中输入“用户”和应用程序启动时生成的密码)。
我的问题是,我现在怎样才能关闭 Spring Security,这样我就看不到登录屏幕了?我不想从我的项目中删除 Spring Security,因为我以后可能会想要它。
我认为这是我的pom.xml 文件的相关部分...
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
/*** ... ***/
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</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 boot Security Disable security
标签: spring-boot spring-security