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*:/*.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、
public
static
String getDirPath() {
Resource resource =
null
;
Properties props =
null
;
String driverClass =
null
;
try
{
resource =
new
ClassPathResource(
"/data.properties"
);
props = PropertiesLoaderUtils.loadProperties(resource);
driverClass= (String) props.get(
"wingPath"
);
}
catch
(IOException e) {
e.printStackTrace();
}
return
driverClass;
}