package com.ui.version.config; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; public class Config { private static Logger log = Logger.getLogger(Config.class.getName()); private static final String fileName = "xiu-ui.properties"; private static final String fileName2 = "com/ui/version/resources/xiu-ui.properties"; private static Properties properties = new Properties();; static{ boolean ready = false; InputStream is = Config.class.getClassLoader().getResourceAsStream(fileName); if(is != null){ try { properties.load(is); ready = true; log.log(Level.INFO, "加载classpath:"+fileName+"成功!"); } catch (IOException e) { log.log(Level.WARNING, "加载classpath:"+fileName+"失败", e); } } if(!ready){ is = Config.class.getClassLoader().getResourceAsStream(fileName2); if(is != null){ try { properties.load(is); ready = true; log.log(Level.INFO, "加载classpath:"+fileName2+"成功!"); } catch (IOException e) { log.log(Level.WARNING, "加载classpath:"+fileName2+"失败", e); } } } if(!ready){ log.log(Level.SEVERE, "未能找到资源,请将"+fileName+"文件放到classes目录下"); } } public static String getConfigValue(String key){ return properties.getProperty(key,null); } public static Properties getProperties(){ return properties; } }
详细解决方案
读取WEB-INF/classes目录上文件,及读取其key-value
热度:402 发布时间:2012-12-17 09:31:40.0
相关解决方案
- 搞了两天了,maven target/classes(回绝访问。)
- 急安装vs2005时出现:1406异常,无法将数值写入键\Software\Classes\.xdr\OpenWithProgids\Shared
- [求助]C:\Tomcat 5.5\webapps\ROOT\WEB-INF\classes
- CSS课程10 CSS的Pseudo Classes 伪类
- myeclipse svn WEB-IF classes update 异常
- 让IE6支持伪种(Pseudo-classes)
- 犀牛书第五版读书笔记――Chapter 9. Classes, Constructors, and Prototypes(第二一部分)
- 犀牛书第五版读书笔记――Chapter 9. Classes, Constructors, and Prototypes(第部分)
- Sencha app build出来的all-classes.js里边的类顺序不对
- 伪种(Pseudo-Classes)&伪对象(Pseudo-Elements)详解
- 犀牛书札记:(11)Classes, Constructors and Prototypes
- 用Static润饰的Nested Classes,只能访问外部类的非static变量
- TIJ英文原版图书阅读之旅——Chapter Seven:Reusing Classes
- No relevant classes found. No output generated.解决方法
- 求指教The following classes could not be found: - DatePicker解决思路
- Part 32 Abstract classes in c
- 报错Duplicate classes in commons-collections and commons-beanutils
- 【Codeforces Round#618 (Div. 2)】B. Assigning to Classes 题解
- IntelliJ IDEA 项目文件旁边都有0%classes,0% lines covered
- idea 中On ‘Update‘ action 下无Update classes and resources选项
- 犀牛书笔记:(11)Classes, Constructors and Prototypes
- iOS Xcode6 AutoLayout跟Size Classes(5)size classes 屏幕旋转的应用
- iOS Xcode6 AutoLayout跟Size Classes(4)size classes 的应用
- iOS Xcode6 AutoLayout跟Size Classes(3)
- iOS Xcode6 AutoLayout跟Size Classes(2)
- iOS Xcode6 AutoLayout跟Size Classes(1)
- Python | Type Object Methods Classes
- Avoiding duplicate symbol errors during linking by removing classes from static libraries
- webstorm编写ES6报错:Classes are not supported by current JavaScript version
- Enhancing custom classes 优化自定义类