1、手动获取加载
Locale locale = Locale.getDefault();
ResourceBundle localResource = ResourceBundle.getBundle("config", locale);
String ztreejdbc = localResource.getString("jdbc_url");
String ztreename = localResource.getString("jdbc_username");
String ztreepassword = localResource.getString("jdbc_password");
2、spring
<context:property-placeholder location="classpath*:/application.properties" ignore-unresolvable="true"/>
@Value("#{configProperties[‘jdbc.jdbcUrl‘]}")
private String jdbcUrl ;
3、
@PropertySource("/conf/jdbc.properties") public class DataSourceConfig { @Value("${jdbc.driverClass}") String driverClass; @Value("${jdbc.url}") String url; @Value("${jdbc.user}") String user; @Value("${jdbc.password}") String password;
4、待续
原文:http://www.cnblogs.com/Struts-pring/p/4986986.html