【问题标题】:Deactivate the TOMCAT security of a Spring Boot application停用 Spring Boot 应用程序的 TOMCAT 安全性
【发布时间】:2021-07-24 19:18:03
【问题描述】:

您好,我使用的是 Spring Boot 2.4.3

我的应用程序是一个 Maven 多模块应用程序,由 Angular/Spring Boot/Spring Security 技术组成。我使用了以下教程:https://spring.io/guides/tutorials/spring-security-and-angular-js/#_the_login_page_angular_js_and_spring_security_part_ii 通过在我的父模块上执行 >mvn clean 包,我创建了一个使用 java -jar backend-0.1-SNAPSHOT.jar 运行的 jar。嵌入的棱角前端功能不错,我测试过了。

通常当我启动 Spring Boot 时,它应该给我一个与“用户”标识符对应的密码,如下图所示

enter image description here

但是当我启动我的 Spring Boot 时,没有显示密码。所以我最终会出现一个身份验证窗口,要求我输入用户和密码

enter image description here

我认为这就是 Spring Boot 中 TOMCAT 服务器的安全性。理想的情况是禁用此安全性,我不知道如何。我做了很多工作却没有找到

我尝试在 application.properties 中添加以下行但没有成功

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration

security.user.name=user
security.user.password=password

spring.security.user.name=user
spring.security.user.password=password

security.basic.enabled=false
management.security.enabled =false

【问题讨论】:

    标签: angular spring-boot spring-security


    【解决方案1】:

    我找到了解决办法

    @Configuration
    @EnableWebSecurity
    public class SecurityConfig extends WebSecurityConfigurerAdapter {
    
        @Override
        protected void configure(HttpSecurity security) throws Exception
        {
         security.httpBasic().disable();
        }
    }
    

    但我只能看到显示的 index.html 页面。该应用程序没有考虑角度路线

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-27
      • 2019-10-09
      • 2015-10-10
      • 1970-01-01
      • 2019-01-02
      • 2021-07-06
      • 2017-01-13
      • 2014-01-07
      相关资源
      最近更新 更多