Java 日志输出工具 & Bean封装工具

These tool are used in work, hence here fimply wirte them for reference afterwards.

1.  Use SLF4J instead of common-logging as log adapter

   SLF4J is new generation of logging framework, that also write by Log4j author, most of open source project already migrate to SLF4J, seems RBP also have used. More information you can reference to: http://www.slf4j.org/ 
   
   use SLF4J instead of common-logging or log4j as log adapter, and still use Log4j as log implementation, so no impact to our exist log configure, just need change the log initialization in Java:

Import 2 jars to project
    
     slf4j-api-1.6.1.jar
     slf4j-log4j12-1.6.1.jar

Import 2 Class in Java

     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;

Initialize Log

     private static final Logger logger = LoggerFactory.getLogger(WPCBatchConstants.BATCH_DEBUGGER);

  That's all, the usage same as our exist, but we will gain some advantage, like:

    - Unneeded log level detect

      if (logger.isDebugEnabled()) { }

      Above statement is not need, SLF4J will help us to do optimize.

    - {} placeholders supported

      logger.debug("This debug log used for {}.", "WPC Batch");

 

2.  Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another.

    If destination object have the same field name as the source object, then will be auto mapped, even the mapped attributes are different data types, the Dozer mapping engine will automatically perform data type conversion. More information please refer to: http://dozer.sourceforge.net/documentation/about.html.
   That will help us convert TO in different layer, like Java Bean to DTO for DAO used.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值