【发布时间】:2019-09-06 04:03:59
【问题描述】:
遵循参考指南为 Spring Boot 管理员 (https://codecentric.github.io/spring-boot-admin/current/) 添加安全性,但在启动应用程序时总是会获得标准登录页面,我无法绕过(并且不确定如何这样做 - 在哪里添加添加登录凭据等等)。现在想设置具有基本安全性的 Spring Boot Admin。
- 创建了一个具有“Spring Boot Admin”和“Spring Security”依赖项的标准启动应用程序
- 将项目导入IDE并在主类中添加@EnableAdminServer注解并运行
注意:
1) 没有向 application.properties 添加任何内容 2)还尝试了使用https://www.baeldung.com/spring-boot-admin的方法,其中使用WebSecurity config显示登录页面,但这会导致出现2个登录窗口(一个作为弹出窗口,第二个作为主页)
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
@EnableAdminServer
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Pom: http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.4.发布 com.example 演示 0.0.1-快照 演示 Spring Boot 演示项目
<properties>
<java.version>1.8</java.version>
<spring-boot-admin.version>2.1.4</spring-boot-admin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</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>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-dependencies</artifactId>
<version>${spring-boot-admin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
希望通过最基本的 Spring Security(使用 Spring Boot 2.x)来保护 Spring Boot Admin
【问题讨论】: