Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **示例:**
- 属性文件 config.properties
- ```
- uploadUrl = "aa.bb.com"
- ```
- java代码
- ```java
- @Configuration@PropertySource("classpath:/com/example/config.properties")
- public class AppConfig {
- @Value("${uploadUrl}") String uploadUrl;
- }
- ```
- **说明:**
- 基于 `@PropertySource` 注解,指定属性文件的路径
- 在启动时,属性文件中的`uploadUrl`的值会自动注入到`AppConfig` 类的`uploadUrl`属性上
Add Comment
Please, Sign In to add comment