SpringBoot
date
Nov 29, 2022
slug
springboot
status
Published
tags
Springboot
summary
SpringBoot
type
Post
mac启动springboot项目很慢的解决解决方案:SpringBoot Jpa 使用 @DynamicInsert 和 @DynamicUpdate@DynamicInsert@DynamicUpdate压缩图片pdf 拼接和涂鸦
mac启动springboot项目很慢的解决
在macOs系统下
启动项目很慢,会有这个信息输出在控制台中:
InetAddress.getLocalHost().getHostName() took 5001 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).
大意是主机名地址解析花了5秒多,请检查你的网络配置(macos的机器名可能需要加入/etc/hosts中)。
解决方案:
在mac的命令终端执行以下命令:
xxx@xxxdeiMac ~ % hostname
xxxdeiMac.local
xxx@xxxdeiMac ~ % sudo vim /private/etc/hosts
# 将你的机器名加入配置中:
127.0.0.1 localhost xxxdeiMac.local
255.255.255.255 broadcasthost
::1 localhost xxxdeiMac.local
:wq #保存即可
SpringBoot Jpa 使用 @DynamicInsert 和 @DynamicUpdate
首先这两个注解是使用在jpa的实体上的,而不是在字段上
@DynamicInsert
设置
value
为true
,表示insert
对象的时候,生成动态的insert语句,如果这个字段的值是null就不会加入到insert
语句当中,默认value
为true
@DynamicUpdate
设置
value
为true
,表示update对象的时候,生成动态的update语句,只更新在jpa
上下文操作变化的字段;也就是它在更新时,会检查在jpa的当前Session上下文中的对象与需要更新的对象数据是否一致,也就是说会确认数据有没有变化,只会更新有变化的字段,而不是只更新不为null的字段;
压缩图片
Github 地址:https://github.com/Curzibn/Luban
pdf 拼接和涂鸦
pdfbox