Spring Boot-IDEA开发技巧

SpringBoot with IDEA

插件

lombok

  • IDEA中下载后

  • 在pom.xml文件中引入依赖

    1
    2
    3
    4
    5
    <dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
    </dependency>
  • 常用注解

    1
    2
    3
    4
    5
    @Builder
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    ...

GsonFormat

  • 可以快速的将JSON转换为实体类
  • shortcut option + s

热部署

  • pom文件中引入依赖

    1
    2
    3
    4
    5
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    </dependency>
  • pom文件中引入依赖

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
    <fork>true</fork>
    </configuration>
    </plugin>
    </plugins>
    </build>
  • Preferences – Compiler – Build project automatically ✅

  • cmd + option + shift + / – registry – compiler.automake.allow.when.app.running – ✅

  • 配置完成后,修改项目文件后会自动build

Kommentare