> Markdown version of [Automatic restart](https://vaadin.com/docs/v10/bakeryflow/auto-restart). Section index: [llms.txt](https://vaadin.com/docs/v10/bakeryflow/llms.txt)

# Automatic restart

There are several tools which can speed up the development process. Using `JRebel`, `spring-boot-devtools` or `HotswapAgent` allows you to see changes without application restart.

## <a id="jrebel"></a>JRebel

To try JRebel for free there is a 2 weeks trial. To start using it follow the instructions for your IDE: <https://zeroturnaround.com/software/jrebel/quickstart/intellij/> or <https://zeroturnaround.com/software/jrebel/quickstart/eclipse/>

JRebel has integration with a lot of frameworks, in particular with `spring-boot`. It allows to substitute modified and recompiled classes into classpath without the application restart.

## <a id="spring-boot-devtools-and-live-reload"></a>Spring-boot-devtools and Live Reload

To activate spring-boot-devtools is needed to:

Add spring-boot-devtools dependency

```
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    <scope>runtime</scope>
</dependency>
```

Fork the process used to run the application by changing spring-boot-maven-plugin configuration

```
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${spring-boot.version}</version>
    <configuration>
        <fork>true</fork>
    </configuration>
</plugin>
```

Create and place into the `src/main/resources/META-INF` the following spring-devtools.properties

```
restart.include.flow=/flow.*\.jar
restart.include.vaadin=/vaadin.*\.jar
```

This means we explicitly define that such jars are unmodifiable and they shouldn’t be reloaded on each application restart. More info at [Customizing the restart classloader](https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-customizing-classload).

Optionally you might want to avoid the data generator to be run on each single reload, therefore, make H2 database store entities in file-system instead of in memory by adding the following lines to the `src/main/resources/application.properties`

```
spring.datasource.url=jdbc:h2:file:~/bakery-test-data
spring.jpa.hibernate.ddl-auto=update
```

To trigger the restart, it is needed to update classpath. In Eclipse it can be done automatically after saving modified file. In IntelliJ IDEA can be done manually `Build → Build Project`

Live reload is supported and browser extensions can be found at <http://livereload.com/extensions/>.

## <a id="hotswapagent"></a>HotswapAgent

To setup HotswapAgent follow the [tutorial](https://hotswapagent.org/mydoc_quickstart.html).

- Start with downloading and installing alternative JVM. Don’t forget to run the installer with administrator privileges.

```
java -jar installer-name.jar
```

- Download manually the HotswapAgent or install the IDE plugin (if you are using IntelliJ IDEA)

- Create Run/Debug configuration which will run the HotswapAgent for [IntellijIDEA](https://hotswapagent.org/mydoc_setup_intellij_idea.html#other-way-its-explicit-agent-configuration-without-plugin) or [Eclipse](https://hotswapagent.org/mydoc_setup_eclipse.html).

For running the app through the HotswapAgent in a Debug session, add this line to the JVM parameters

```
-XXaltjvm=dcevm -javaagent:PATH_TO_AGENT/hotswap-agent.jar
```

But if you rather a Run session, you need to set `autoHotswap` flag in the parameters

```
-XXaltjvm=dcevm -javaagent:PATH_TO_AGENT/hotswap-agent.jar=autoHotswap=true
```

> **Note:** For IntelliJ IDEA there is a [HotswapAgent plugin](https://hotswapagent.org/mydoc_setup_intellij_idea.html#start-with-hotswapagent-plugin-for-intellij-idea) which works with debug session only. It doesn’t support the `autoHotswap` flag. It’s needed to setup Run/Debug configuration manually for running without debug session.

If you prefer to run application via command line, you just need to set the JVM parameters via the MAVEN\_OPTS environment variable:

```
MAVEN_OPTS="-XXaltjvm=dcevm -javaagent:PATH_TO_AGENT/hotswap-agent.jar=autoHotswap=true" mvn spring-boot:ru
```
