• Source: Internet

A, SpringBoot Dedevtools

It is a tool to enable SpringBoot to support hot deployment. The following methods are referenced either by checking the following configuration when creating a project:

Or add the following dependencies to the springBoot project:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
Copy the code

If you want to modify the code, the code will be automatically recompiled, no need to press CTRL + F9. Just do the following:

1. Check the following boxes in setting of idea

2. Go to Pom.xml, place a cursor after the build tag, then press Alt+Shift+ CTRL +/

3. Select the following items and restart IDEA

Second, the Lombok

Lombok is a tool to simplify JavaBean development by eliminating the need to write constructors, getters, and setters. To use Lombok, check the following configuration at project initialization

Or import the following dependencies in your project:

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
</dependency>
Copy the code

To use idea, you also need to download the following plug-ins:

Here’s an example of how to use it

import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; Constructor @noargsconstructor @data //getter + setter public class User {private Long id; private String name; private Integer age; private String email; }Copy the code

3. Spring Configuration Processor

This tool is to the entity class attribute injection open prompt, I feel the tool significance is not particularly big! Because SpringBoot has property injection, such as the following entity class:

package org.lzl.HelloWorld.entity; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; /** * @author Lenovo * */ @Component @ConfigurationProperties(prefix = "mypet") public class Pet { private String nickName; private String strain; public String getNickName() { return nickName; } public void setNickName(String nickName) { this.nickName = nickName; } public String getStrain() { return strain; } public void setStrain(String strain) { this.strain = strain; } @Override public String toString() { return "Pet [nickName=" + nickName + ", strain=" + strain + "]"; }}Copy the code

Properties and application.yml, but there is no prompt to inject mypet properties into application.properties and application.yml. To solve this problem, we checked the following scenario when creating SpringBoot:

Or add the following dependencies directly to the project:

<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-configuration-processor</artifactId>
     <optional>true</optional>
 </dependency>
Copy the code

And exclude packaging of the tool from the build tag :(reduce the size of the jar package)

<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId>  <configuration> <excludes> <exclude> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build>Copy the code