zoukankan      html  css  js  c++  java
  • 周记 2014.8.31

    1. apache-maven-3.2.1-bin.zip和apache-maven-3.2.1-src.zip两个文件中,带有bin的为安装运行文件。

    2. 阻塞队列:

        add        增加一个元索                     如果队列已满,则抛出一个IIIegaISlabEepeplian异常

        remove   移除并返回队列头部的元素    如果队列为空,则抛出一个NoSuchElementException异常

        element  返回队列头部的元素             如果队列为空,则抛出一个NoSuchElementException异常

        offer       添加一个元素并返回true       如果队列已满,则返回false

        poll         移除并返问队列头部的元素    如果队列为空,则返回null

        peek       返回队列头部的元素             如果队列为空,则返回null

        put         添加一个元素                      如果队列满,则阻塞

        take        移除并返回队列头部的元素     如果队列为空,则阻塞

    3. 执行含有主方法(main)的jar文件,java  -jar  **.jar

    4. 获取字符串二进制代码时,getByte一般使用getByte(“utf-8”)来防止中文乱码

    5. 使用“|”进行切割,需要“\|”进行转义。

    6. 使用Tomcat启动服务,可以在Tomcat目录下的logs中查看Tomcat日志。

    7. 缓存更新策略:去缓存中查询,若缓存中没有,再去数据库中查询,如果数据库中有,获取数据返回,同时更新缓存

    8. 日志记录非常重要。将log4j.properties文件,放到jar包外面,为保证配置文件加载,可以执行下列代码:

    String uri = ConfigTool.getConfigUri("log4j.properties");
    if(null != uri){
          PropertyConfigurator.configure(uri);
    }
    public static String getConfigUri(String fileName) {
    
            String r = null;
    
            if((new File(fileName)).exists()){
                return fileName;
            }
            
            String userDir = System.getProperty("user.dir");
            File confInDir = new File(userDir + File.separator + fileName);
            URL confInClassPath = ConfigTool.class.getResource("/" + fileName);
            if (null != confInClassPath && confInDir.exists()) {
                r = confInClassPath.toString();
            } else if (confInDir.exists()) {
                r = confInDir.getAbsolutePath();
            } else {
                URL uri = ConfigTool.class.getResource(fileName);
                if(null != uri){
                    r = uri.toString();
                }
            }
            return r;
        }

     

    9. System.getProperty("user.dir"); // 当前程序所在项目目录。适用于jar文件,在tomcat目录中的到的是bin目录。

    10. 打jar包时,把配置文件放到jar包外面,便于配置文件的修改。通过第8条的方式加载文件。

    11. 定时任务中,当使用连接池中的连接时,应考虑使用单例模式,不要每次从连接池中取新的连接。

     

  • 相关阅读:
    Codeforces Round #370 (Div. 2)
    Codeforces Round #425 (Div. 2)
    变量调节器
    Smarty基础
    流程
    iframe 内联框架
    权限:改变权限
    权限:查找
    html 框架
    Jcrop+uploadify+php实现上传头像预览裁剪
  • 原文地址:https://www.cnblogs.com/Jtianlin/p/3947839.html
Copyright © 2011-2022 走看看