zoukankan      html  css  js  c++  java
  • 关于在Websphere下程序找不到jar包内.properties文件的问题

     
    关于在Websphere下程序找不到jar包内.properties文件的问题
    问题描述: 

    最近在测试V3.1.1时,发现AM部署在websphere下程序会提示找不到jar包内的 *.properties 文件问题 

    程序写法类似如下: 

    this.getClass().getResource("/xxxxxxx.properties") (这种写法在tomcat下可行) 


    问题原因: 在tomcat和websphere 下类加载方式实现不一样 导致的 

    已经按照以下方式在Websphere下进行测试,均行不通: 
    Thread.currentThread().getContextClassLoader().getResourceAsStream("/xxxxxxxx.properties") 
    this.getClass().getResourceAsStream("/xxxxxxx.properties") 
    Thread.currentThread().getContextClassLoader().getResource("").toURI().getPath().toString()+"/xxxxxxxx.properties"; 
    getClass().getClassLoader().getResourceAsStream("/xxxxxxxx.properties") 
    Spring的ClassPathResource尚未测试 

    注:考虑到不同中间件兼容性问题,如果非必须,不建议把.properties文件 打入jar包!
     
    最近开通的博客园,把这两年记录下来的问题分享出来,也算是自己有个记录,同时也可以帮助到遇到相同问题的人。
  • 相关阅读:
    hadoop 2.x 简单实现wordCount
    httpClient连接超时设置
    Java io使用简介
    log4j使用教程
    F#中的自定义隐式转换
    Computation expressions and wrapper types
    Introducing 'bind'
    Understanding continuations
    Computation expressions: Introduction
    MySQL优化总结,百万级数据库优化方案
  • 原文地址:https://www.cnblogs.com/wuyuxiang/p/5166336.html
Copyright © 2011-2022 走看看