栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 软件开发 > 后端开发 > Java

小小的SB磨合之路

Java 更新时间:发布时间: 百科书网 趣学号
  1. 2021.09.26 SpringBoot自带的序列化工具是fasterxml的Jackson,今天有三个个问题?
    1) 如何搜索任意key
    (部分)JsonNode的findValue方法
    2) 什么时候使用ObjectMapper的readValue,什么时候使用readToTree
    readvalue-and-readtree-in-jackson-when-to-use-which

    readValue() can be used for any and all types, including JsonNode. readTree() only works for JsonNode (tree model); and is added for convenience.


    3) Json String中对应内部静态类字段不存在时反序列化后这个域是否存在
    不存在,为null,也就是说无参构造函数并没有执行,仔细想想,都没有识别到它的存在,为什么要执行构造函数

  2. 2021.09.23 谁引入了这个jar?
    某个类缺少一个方法,毫无疑问是版本不兼容,这个问题又来了(我在2019年8月遇到过一次);
    jar: servelet-api-2.3.jar
    class: javax.servlet.http.HttpServletResponse
    谁引入的这个jar?怎么找到pom依赖三元素?笨!jar文件前面Idea那里显示的就是三元素,输进maven helper分析即可

  3. 2021.09.22 @Configuration类是个什么类,起什么作用?待答
    JPA定义的entity字段有NOT_NULL限制,也有defaultValue(数据库定义字段),为什么写不进去:not-null propertites reference a null or trasient value 因为写入数据库的语句肯定相应字段是null那么问题就变成了,JPA如何不更新某个字段但是读的时候要把该字段读出来?
    配置updatable = false即不更新这个字段
    或者
    联合字段注解@UpdatedDate 、entity上加注解@EntityListeners、任意类上注解@EnableJpaAuditing自动set日期字段 creation-timestamp-and-last-update-timestamp-with-hibernate-and-mysql
    解决updatetime字段问题后,新问题是用dao(CrudRepository)保存这个entity后立即查询出更新时间却为null,使用另一http请求访问却可以查出来:
    原因是open-in-view Spring Boot中建议关闭Open-EntityManager-in-view
    spring-open-session-in-view 建议细读
    what-is-this-spring-jpa-open-in-view-true-property-in-spring-boot 建议细读

  4. DI 注入方式与@Autowired(因为Idea不建议Field反射注入: Field inject is not recommended)
    setter 注解在setter方法上
    constructor 注解在构造方法上
    Field反射 注解在Field上
    配置注入 yaml先看-D jvm参数,再看系统环境变量

  5. Jackson序列化与反序列化相关注解 待答

  6. 3年前的疑问: Could not autowired: No beans of "kafkaProperties" type found----> @CompnentsScan

  7. CrudRepository没有update方法,怎么update? how-do-i-update-an-entity-using-spring-data-jpa 中文CSDN博客:工作单元模式:Unit of Work 对某个业务操作,比如银行的进出账的业务对象(进账对象,出账对象)进行统一管理,使它们不需要在自己的repository中提交(commit),放在工作单元中做持久化工作

    In this case you have a set of objects managed by persistence library. All changes you make to these objects will be flushed to the database automatically at the end of Unit of Work (i.e. at the end of the current transaction in typical case). When you need to insert new record to the database, you make the corresponding object managed. Managed objects are identified by their primary keys, so that if you make an object with predefined primary key managed, it will be associated with the database record of the same id, and state of this object will be propagated to that record automatically.

转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/270403.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号