zoukankan      html  css  js  c++  java
  • 1.4 引用lombak 省去bean中的 get set

    1.引包

    <!--加入可以省略get set 方法的插件工具-->
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
    </dependency>

    2.idea中安装插件

     3.实体类代码

    @Entity
    @DynamicUpdate  // 动态自动更新时间
    @Proxy(lazy = false)  // 懒加载设置为false
    @Data   // 包含了get set toString方法 也可以直接用@Getter @Setter  
    public class ProductCategory { // 类目 @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer categoryId; // 类目名字 private String categoryName; // 类目编号 private Integer categoryType;
      //private Date createTime;
      //private Date updateTime;
    }

    4.测试

    @RunWith(SpringRunner.class)
    @SpringBootTest
    @Slf4j
    public class ProductCategoryRepositoryTest {
    
        @Autowired
        private ProductCategoryRepository repository;
    
        @Test
        public void findOneTest() {
    //        ProductCategory producCategory = repository.getOne(1);
    
            Optional<ProductCategory> producCategory = repository.findById(1);
            log.info(producCategory.toString());
        }
    
        @Test
        public void saveTest(){
    //        ProductCategory productCategory = new ProductCategory();
    //        productCategory.setCategoryName("女生最爱");
    
            ProductCategory productCategory = repository.getOne(1);
            productCategory.setCategoryType(5);
            repository.save(productCategory);
        }
    }
  • 相关阅读:
    JavaScript通过HTML的class来获取HTML元素的方法总结
    HTML5之FileReader接口读取文件
    简单好用用js就可以保存文本文件到本地
    JS获取节点的兄弟,父级,子级元素的方法
    删除window里面删除不掉的文件
    《软件过程改进》练习题
    软件过程改进2016下半年真题及答案
    jquery
    JSP入门
    JAVA方法
  • 原文地址:https://www.cnblogs.com/qinls/p/9909641.html
Copyright © 2011-2022 走看看