Weekly log on March 31

Source: Internet
Author: User

1.apache-maven-3.2.1-bin.zipand apache-maven-3.2.1-src.zip files.

2. Blocking queue:

AddIf the queue is full, an iiiegaislabeepeplian exception is thrown.
RemoveRemoves and returns the element in the queue header. If the queue is empty, a nosuchelementexception exception is thrown.
ElementReturns the element in the queue header. If the queue is empty, a nosuchelementexception exception is thrown.
OfferAdd an element and return true. If the queue is full, return false.
PollRemoves and returns the element in the queue header. If the queue is empty, null is returned.
PeekReturns the element in the queue header. If the queue is empty, null is returned.
PutAdd an element. If the queue is full, it is blocked.
TakeRemove and return the elements in the queue header. If the queue is empty, it is blocked.

3. Execute the JAR file containing the main method (main), Java-jar **. Jar

4. getbyte generally uses getbyte ("UTF-8") to prevent Chinese garbled characters when obtaining string binary code.

5. When "|" is used for cutting, escape is required.

6. Use tomcat to start the service. You can view Tomcat logs in the logs directory of Tomcat.

7. cache update policy: query in the cache. If the cache does not exist, query in the database. If there is any in the database, get the data and return it. At the same time, update the cache.

8. log records are very important. Place the log4j. properties file outside the jar package. To ensure that the configuration file is loaded, run the following code:

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"); // directory of the project where the current program is located

10. Put the configuration file out of the jar package to facilitate modification of the configuration file. Load files in 8th ways.

11. In a scheduled task, when using connections in the connection pool, you should consider using the singleton mode. Do not retrieve new connections from the connection pool each time.

 

Weekly log on March 31

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.