SpringBoot学习笔记

1.-------------------  读取application.properties配置文件 ------------------- 

application.properties内容:

book.name=springboot
book.number=${random.value}

读取代码

@RestController
public class HelloController {

    @Value("${book.name}")
    private String name;

    @Value("${book.number}")
    private String number;

    @RequestMapping("/hello")
    public String index() {
        return "Hello World " + name + " " + number;
    }
}

 

2. ------------------- 设置多配置文件 ------------------- 

 

3.------------------- 在启动时可以修改配置文件属性如下修改启动端口号,在用命令行方式启动Spring Boot 应用时, 连续的两个减号--就是对application.propertier 中的属性值进行赋值的标识。 -------------------

java -jar xxx.jar --server.part= 8888

 

4.------------------- actuator 可查看监控数据 ----------------------------

http://127.0.0.1:8080/actuator

http://127.0.0.1:8080/actuator/env

http://127.0.0.1:8080/actuator/metrics

http://127.0.0.1:8080/actuator/shutdown  //优雅关闭springboot

 

posted on 2019-04-20 17:25  上校  阅读(257)  评论(0编辑  收藏  举报