标签:frame 配置 nbsp blog one logs div bean autowired
1. application.properties配置文件增加配置项
myconfig.item.url=http://127.0.0.1:8080/proj/test
2. 写一个常量类
import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component("constants") public class Constants { @Value("${myconfig.item.url}") private String myconfigItemUrl; public String getMyconfigItemUrl() { return myconfigItemUrl; } }
3. 其他代码中使用
@Autowired private Constants constants; public void test(){ String url = constants.getMyconfigItemUrl(); }
标签:frame 配置 nbsp blog one logs div bean autowired
原文地址:http://www.cnblogs.com/zj0208/p/6362139.html