spring boot开发记录
热部署
maven中添加下面的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
启动jar时,修改log级别
java -jar myapp.jar --debug
切换命令行maven的JDK版本
# 重点在于修改JAVA_HOME环境变量
# git bash
export JAVA_HOME="/c/Program Files/Eclipse Adoptium/jdk-17.0.4.8-hotspot"
# or
declare -x JAVA_HOME="/c/Program Files/Eclipse Adoptium/jdk-17.0.4.8-hotspot"
# linux
JAVA_HOME=/opt/jdk8u265-b01
切换命令行java的JDK版本
# 重点在于修改PATH环境变量
export PATH="/c/Program Files/Eclipse Adoptium/jdk-17.0.4.8-hotspot/bin:$PATH"
序列化对象时的jackson设置
// 不输出该字段
@com.fasterxml.jackson.annotation.JsonIgnore
private int intValue;
// 设置日期的输出格式
@com.fasterxml.jackson.annotation.JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
private Date date;
// 忽略为null的字段
@com.fasterxml.jackson.annotation.JsonInclude(Include.NON_NULL)
class Foo
{
String bar;
}
// 解析日期格式输入
@org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date date;
输入中包含文件
// 不使用json形式提交+@RequestBody, 改用传统form
reference
- Hot swapping in Spring Boot in Visual Studio Code
- 26. Logging
- settings - Specify JDK for Maven to use - Stack Overflow
- bash - What is the difference between set, env, declare and export when setting a variable in a Linux shell? - Super User
- Date format Mapping to JSON Jackson
- Jackson Ignore Properties on Marshalling | Baeldung
- java - How to tell Jackson to ignore a field during serialization if its value is null? - Stack Overflow
- All You Need To Know About JSON Parsing With Jackson
- java - Content type ‘multipart/form-data;boundary=—-…;charset=UTF-8’ not supported - Stack Overflow
Updated: 2023-08-06 17:14
Created: 2023-04-25 20:00