• lombok插件:Data自动get/set方法, Slf4j实现Logger的调用


    lombok插件:Data自动get/set方法, Slf4j实现Logger的调用

    lombok.Data

    import lombok.Data;
    import org.hibernate.annotations.DynamicUpdate;
    
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import java.io.Serializable;
    import java.sql.Date;
    
    @Entity
    @Data //默认添加get/set/toString方法
    @DynamicUpdate //update_timestamp自动更新时间
    public class ProductCategory implements Serializable {
    
    	@Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Integer categoryId;
    
        private String categoryName;
    
        private Integer categoryType;
    
        private Date createTimestamp;
    
        private Date updateTimestamp;
    
        public ProductCategory()
        {
    
        }
        public ProductCategory(String categoryName, Integer categoryType)
        {
            this.categoryName = categoryName;
            this.categoryType = categoryType;
        }
    
    }
    

      

    lombok.extern.slf4j.Slf4j
    import lombok.extern.slf4j.Slf4j;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;
    
    @RunWith(SpringRunner.class)
    @SpringBootTest
    @Slf4j
    public class LoggerTest {
    
        //private static final Logger log = LoggerFactory.getLogger(LoggerTest.class);
    
        @Test
        public void test1()
        {
            String name= "zhangsan";
            String password = "123456";
    
            log.debug("debug:  "+name+",  "+password);
            log.info("info: {}, {}", name, password);
            log.error("error...... ");
    
        }
    }
    

      

  • 相关阅读:
    sqoop 使用场景
    scala 类型和集合图
    scala 格式化操作
    sqoop 基础
    scala import 总结
    shell错误 syntax error: invalid arithmetic operator (error token is "
    C/C++ 隐式申明 问题
    阿里云贾扬清:数据湖正成为企业数据应用创新标配
    云原生时代如何用 Prometheus 实现性能压测可观测Metrics 篇
    基于 KubeVela 的机器学习实践
  • 原文地址:https://www.cnblogs.com/achengmu/p/9944796.html
Copyright © 2020-2023  润新知