zoukankan      html  css  js  c++  java
  • xxx.properties获取方法

    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;
             
        }
  • 相关阅读:
    让UIButton在按下时没有高亮效果
    如何让View一直沿z轴旋转
    App 应用通过网页打开 App Store
    Xcode/iOS: 如何判断代码运行在DEBUG还是RELEASE模式下?
    freemyapps 推荐链接
    [转]Git使用基础篇
    [转]anchorPoint 锚点解析
    Mac下如何看Swf文件
    Xcode 5: 将新项目同步到Svn上
    Shell 启动java程序
  • 原文地址:https://www.cnblogs.com/Struts-pring/p/4986986.html
Copyright © 2011-2022 走看看