zoukankan      html  css  js  c++  java
  • jboss下部署失败,原因是i18n配置文件读取错误,改为如下

    public class I18nResourceBundleMessageSource extends

    ResourceBundleMessageSource {


    private static Log log = LogFactory

    .getLog(I18nResourceBundleMessageSource.class);


    /**

    * 重载父类的方法 ,支持在WEB-INF/classes下 以 basename

    * 来匹配国际化资源文件,basename取值一般是message_*.properties

    * 要求国际化资源文件 是这个格式:message_模块名_实体名_locale.properties

    */

    @Override

    public void setBasename(String basename) {

    try {

    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

    // 通过模式匹配加载多个模式匹配的Resource

    Resource[] resources = resolver

    .getResources("classpath*:message_*.properties");

    Set<String> baseNameSet = new HashSet<String>();

    for (int i = 0; i < resources.length; i++) {

    Resource r = resources[i];

    String fileName = r.getFilename();

    log.info("Reading i18n properties: " + fileName);


    Pattern p = Pattern.compile("message_[a-zA-Z]+_[a-zA-Z]+");

    Matcher matcher = p.matcher(fileName);

    if (matcher.find()) {

    fileName = matcher.group();

    baseNameSet.add(fileName);

    }

    }


    String[] baseNames = (String[]) baseNameSet

    .toArray(new String[baseNameSet.size()]);

    setBasenames(baseNames);

    } catch (IOException ex) {

    throw new SystemException("Reading i18n properties error.", ex);

    }


    /*

    * List<String> baseNameList = new ArrayList<String>(); String path =

    * ""; try { path = CommUtil.getInstance().getWebInfPath(); } catch

    * (IllegalAccessException e) { throw new

    * SystemException("获取国际化文件路径出错",e); }

    * //File dir = new File( path + "classes/i18n" ); File dir = new File(

    * path + "classes" );

    * FileFilter fileFilter = new WildcardFileFilter(basename); File[]

    * files = dir.listFiles(fileFilter); String fileName = null; try { for

    * (int i=0;i< files.length;i++){ fileName = files[i].getName(); int

    * index = fileName.indexOf("_"); index = fileName.indexOf("_",

    * index+1); index = fileName.indexOf("_", index+1);

    * //fileName = "i18n/" +fileName.substring(0,index); fileName =

    * fileName.substring(0,index);

    * if (! baseNameList.contains(fileName)) { baseNameList.add(fileName);

    * } } } catch (Exception e) { throw new SystemException("读取国际化资源文件" +

    * fileName + "出错",e); }

    * String[] baseNames = (String[]) baseNameList.toArray(new

    * String[baseNameList.size()]); setBasenames(baseNames);

    */

    }



    }


  • 相关阅读:
    nodejs微服务
    node 操作文件流 fs 同步与异步 流式文件的写入与读取
    node判断文件目录是否存在
    Nodejs 使用 Chrome DevTools 调试 --inspect-brk
    使用ovftool工具实现exsi上主机的导入导出
    redis哨兵
    LVS+Nginx
    nginx的proxy代理缓存
    flanneld启动报错Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
    flanneld启动报错Failed to create SubnetManager: parse first path segment in URL cannot contain colon
  • 原文地址:https://www.cnblogs.com/danghuijian/p/4399999.html
Copyright © 2011-2022 走看看