spring boot——读取应用配置——方式二——@Value
=========================================================================================
读取数据并显示:
package org.example.controller; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class ValueReaderConfigController { @Value("${test.environment}") private String msg; // http://localhost:8080/testValue @RequestMapping("/testValue") public String testValue() { return "方法二:" + msg; } }
===============================================================================