@PropertySource注解的使用及读取自定义的properties文件
一、@PropertySource注解
若要读取项目yml或者properties配置文件里的属性,可以使用@ConfigurationProperties注解;
如果我们想读取自定义的properties文件,可以使用@PropertySource注解。此注解有一个value属性,@PropertySource(value = “classpath:/config/ssoConfig.properties”),其值为自定义配置文件的路径。
二、第一种用法
@Component、@PropertySource和@ConfigurationProperties三个注解及一个实体类,可以实现读取自定义配置文件:
@Component
@PropertySource(value = "classpath:/config/ssoConfig.properties")
@ConfigurationProperties(prefix = "sso.config")
public