其他分享
首页 > 其他分享> > spring加载配置文件的2种方式

spring加载配置文件的2种方式

作者:互联网

1.配置方式
property-placeholder

<context: property-placeholder ignore-unresolvable="true" location="xxxx.properties"/>

2.注解方式
@PropertySource(value={“classpath:redis-key.properties”})

@PropertySource(value={"classpath:xxxx.properties"})
public class ReadProperties {
@Value(value="${文件中的key}")
 private String USER_NAME;
}

标签:PropertySource,方式,配置文件,spring,classpath,value,key,properties,加载
来源: https://blog.csdn.net/qq_40850266/article/details/119236853