首页 > 技术文章 > Spring 读取配置文件的俩种方式

pengyusong 2017-01-13 16:40 原文

读取配置可通过 org.springframework.core.env.Environment 类来获取, 也可以通过@Value的方式来获取

 

注解形式:

@PropertySource({"classpath:application.properties"})

 

配置文件形式:

<context:property-placeholder location="classpath:jdbc.properties" file-encoding="utf-8" ignore-unresolvable="true" />

推荐阅读