码迷,mamicode.com
首页 > 移动开发 > 详细

Spring Boot—07应用application.properties中的配置

时间:2018-04-23 19:55:56      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:webconfig   web   eth   ret   cat   image   app   efi   round   


方法1

@Value("${test.msg}")  
    private String msg;


方法2

@Autowired  
private Environment env;
String value = env.getProperty("test.msg");


方法3

@RequestMapping(path="/${query.all}.json", method=RequestMethod.GET)
@ResponseBody
public List<User> all() {
    return userService.allUser();
}


方法4

@Component  
@ConfigurationProperties(prefix = "author",locations = "classpath:author.properties")     
public class MyWebConfig{  
    private String name;  
    private int age;

Spring Boot—07应用application.properties中的配置

标签:webconfig   web   eth   ret   cat   image   app   efi   round   

原文地址:https://www.cnblogs.com/gispathfinder/p/8921103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!