Guest User

Untitled

a guest
Feb 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. **示例:**
  2.  
  3. 属性文件 config.properties
  4. ```
  5. uploadUrl = "aa.bb.com"
  6. ```
  7. java代码
  8. ```java
  9. @Configuration@PropertySource("classpath:/com/example/config.properties")
  10. public class AppConfig {
  11. @Value("${uploadUrl}") String uploadUrl;
  12. }
  13. ```
  14. **说明:**
  15. 基于 `@PropertySource` 注解,指定属性文件的路径
  16. 在启动时,属性文件中的`uploadUrl`的值会自动注入到`AppConfig` 类的`uploadUrl`属性上
Add Comment
Please, Sign In to add comment