In my Spring Boot (2.6.4) project I would like to know if it is possible to make changes to a class (for example entity, DTO or controller) and have the changed classes reload without having to restart the whole application (like here)
My environment consists of: IDE: Intellij Idea 2023 Ultimate Build Tool: Gradle
I have enabled the options in Intellij for:
- Settings->Build, Execution, Deployment->Compiler : Build Project Automatically (ticked)
- Enabled option 'allow auto-make to start even if developed application is currently running' in Settings -> Advanced Settings under compiler
In gradle I have tried both options:
developmentOnly 'org.springframework.boot:spring-boot-devtools'
and
compileOnly 'org.springframework.boot:spring-boot-devtools'
I am Debugging the project in Intellij using the Green Debug icon on the tool menu.
I then tried to make a change to a Dto class while running the project in Debug, for example:
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class CarDto {
@JsonProperty("carId")
private Long carId;
@JsonProperty("name")
private String name;
}
By commenting out the two lines:
//@JsonProperty("name")
//private String name;
But there is no indication on the terminal in Intellij that it has detected the changes and reloaded the changed classes.
UPDATED
Another more recent post states that it is controlled by the run configuration in Intellij.
It states:
- Install Spring Boot Developer tools;
- Set the
On Update Action
inRun Configuration
toHot swap classes and update trigger file if failed
On Frame deactivation
have the class `Update Classes and Resources'
Q: How can I get the live reload to work - it appears there is a few different sets of instructions.
I can post more of the build.gradle
if needed.