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...... "); }
}