关闭弹簧启动器的执行器安全性

时间:2018-07-31 18:42:34

标签: spring-boot spring-boot-actuator

我正在lynda.com上查看spring-boot教程 https://www.lynda.com/Spring-tutorials/Spring-Boot-Actuator/653258/709599-4.html?autoplay=true 演示者只是说关闭 管理安全 这就是application.yml的样子

management:
  security:
  enabled: false
---
spring:
  profiles: dev
server:
  port:8000
---
spring:
  profiles: test
server:
  port:9000

这就是主类的样子

package com.frankmoley.boot.essentials.initialbootapp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class InitialBootAppApplication {

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

    @RestController
    @RequestMapping("/api")
    public class ApiController {
        @GetMapping("/greeting")
        public String getGreeting() {
            return "Hey, this is my custom string message!!!";
        }
    }
}

现在,他没有经过任何明确的登录或此处的身份验证。如果关闭了安全性,它应该让我看到localhost:8080 / mappings和localhost:8080 / health也应该向我显示整个消息。 但是,我看不到额外的信息。 在我的日志中,我看到了这段文字

2018-07-31 13:35:01.048  INFO 5068 --- [nio-8080-exec-2] s.b.a.e.m.MvcEndpointSecurityInterceptor : Full authentication is required to access actuator endpoints. Consider adding Spring Security or set 'management.security.enabled' to false.

有没有办法将application.yml设置为默认属性文件,我在这里缺少什么?

1 个答案:

答案 0 :(得分:2)

您的yml文件中可能有错误。为“已启用”添加缩进。

management:
  security:
    enabled: false

或者您可以使用属性文件(.properties),这可能对您更易读:

management.security.enabled=false
相关问题