两种方式:
1. 将properties文件路径加入到spring配置文件中,如下:
<!-- 加载资源文件 -->
<context:property-placeholder location="classpath:system-db.properties" file-encoding="utf-8"ignore-unresolvable="true"/>
标签,如下:
@PropertySource(value = "classpath:system-db.properties", encoding = "utf-8")
使用方式:
在spring上下文中定义相应的属性,并使用注解注入配置文件中的值,如下:
@Value("${alidayu.url}")private String url;