SpringBoot學習筆記

1.-------------------  讀取application.properties配置文件 ------------------- java

application.properties內容:spring

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

讀取代碼springboot

@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. ------------------- 設置多配置文件 ------------------- app

 

3.------------------- 在啓動時能夠修改配置文件屬性以下修改啓動端口號,在用命令行方式啓動Spring Boot 應用時, 連續的兩個減號--就是對application.propertier 中的屬性值進行賦值的標識。 -------------------dom

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

 

4.------------------- actuator 可查看監控數據 ----------------------------命令行

http://127.0.0.1:8080/actuatorcode

http://127.0.0.1:8080/actuator/envserver

http://127.0.0.1:8080/actuator/metricsblog

http://127.0.0.1:8080/actuator/shutdown  //優雅關閉springboot

相關文章
相關標籤/搜索