Skip to content

Instantly share code, notes, and snippets.

@msh01
Last active February 10, 2018 02:03
Show Gist options
  • Save msh01/9f4135757b5d8bf4336063aa96c5e62d to your computer and use it in GitHub Desktop.
Save msh01/9f4135757b5d8bf4336063aa96c5e62d to your computer and use it in GitHub Desktop.

示例:

属性文件 config.properties

uploadUrl = "aa.bb.com"

java代码

@Configuration@PropertySource("classpath:/com/example/config.properties")
public class AppConfig {
@Value("${uploadUrl}") String uploadUrl;
}

说明: 基于 @PropertySource 注解,指定属性文件的路径 在启动时,属性文件中的uploadUrl的值会自动注入到AppConfig 类的uploadUrl属性上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment