Last active
December 20, 2015 02:49
-
-
Save aliencode/6059598 to your computer and use it in GitHub Desktop.
读取Properties配置文件值
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- 引用 --> | |
| <context:property-placeholder ignore-resource-not-found="true" | |
| location="classpath*:/application.properties,classpath*:/application.development.properties"/> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Value( "${jdbc.url}" ) | |
| private String jdbcUrl; | |
| //spring property placeholders 使用: ${key:defaultValue} | |
| //或 | |
| @Autowired | |
| private Environment env; | |
| ... | |
| env.getProperty("jdbc.url"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment