1, SpringBoot Dedevtools
It is a tool to enable SpringBoot to support hot deployment, and here is how it is referenced
Or check the following configuration directly when creating the 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
-
Idea after modifying the code, press CTRL + F9 to recompile it, which completes the hot deployment function
-
Eclipse is automatically compiled by pressing CTRL + S to save
If you want to automatically recompile the code as soon as you change it, 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
2, 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
@allargsconstructor @noargsconstructor @data //getter + setterPublic 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:
@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
PS: In case you can’t find this article, please click “like” to browse and find it