【问题标题】:SpringBoot security on heroku-deployed project even without using its dependency即使不使用依赖项,heroku-deploy 项目上的 Spring Boot 安全性
【发布时间】:2022-01-27 03:37:47
【问题描述】:

我正在为 Gradle SpringBoot restAPI 使用 java 1.8。
我没有使用 spring-boot-starter-security 并且 API 可以相应地工作,但是在 heroku 上部署相同的代码后,API 会要求注册。

我尝试通过以下方式禁用它,

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;

@SpringBootApplication (exclude = { SecurityAutoConfiguration.class })
public class LawCaseApplication {

    public static void main(String[] args) {
        SpringApplication.run(LawCaseApplication.class, args);
    }

}

但重新部署后屏幕仍然出现。 然后我尝试通过在 application.properties 中写入以下内容来为其提供我自己的用户名和密码,因为我也没有在日志中获得任何随机生成的密码,

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

我仍然得到这个屏幕。

但是,我使用的依赖项是,

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.projectlombok:lombok:1.18.20'
    runtimeOnly 'org.postgresql:postgresql'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation "org.jsoup:jsoup:1.13.1"
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
}

我再说一遍,在本地主机上运行但在 heroku 部署版本上运行时没有安全性。

【问题讨论】:

    标签: java heroku spring-security spring-boot-gradle-plugin


    【解决方案1】:

    其实,每次重新部署之前,都有一个最重要的步骤。 构建 jar/war 文件,以便根据您最近所做的更改对其进行更新...

    您使用的步骤在 localhost 上工作,证明它们是正确的...... 尝试构建 jar/war 文件,然后检查它是否有效...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-04
      • 2020-09-03
      • 2012-03-27
      • 2019-07-28
      • 2017-05-17
      • 2019-03-14
      • 2021-04-05
      • 2018-03-09
      相关资源
      最近更新 更多