3

我正在将 Spring Boot ( 1.3.0) 与 Jersey 一起使用(pom 依赖项:spring-boot-starter-jersey、、、、spring-boot-starter-actuator)。spring-boot-starter-webspring-boot-starter-security

我有一个 Jersey 端点(见下文),它非常简单:

@Component
@Path("/helloworld")
public class HelloWorldResource {

    @GET
    public String home() {
        return "Hello World !";
    }
}

server.servlet-path=/system我通过为 Spring MVC url ( )设置特定路径来启用 Spring Boot Actuator ,如Spring Boot guide中所述。
多亏了spring-boot-starter-security,Actuator 端点通过基本身份验证得到保护。

我的问题是它/helloworld也是安全的,但我想让它不安全。

我怎样才能做到这一点 ?

谢谢 !

4

2 回答 2

6

您必须在 yaml/properties 文件中配置设置,如下所示 -

server:
  port: 8080
  context-path: /MyApplication

security:
   user:
       name: admin
       password: secret
   basic:
       enabled: false

management:
   context-path: /actuator
   security:
             enabled: true

因此,对于您的应用程序,安全性被禁用,但对执行器端点启用。确保您没有在管理安全下配置用户名/密码,否则它将无法正常工作。

于 2016-09-19T11:29:30.700 回答
0

您可以将security.user.name属性与配置一起添加management.security.role到您的配置中,例如application.propertiesspring cloud 配置中心的配置,并在启动日志中搜索随机密码。当然,您也可以添加密码bootstrap.yml以使用您指定的密码。

于 2016-05-02T00:17:51.950 回答