Docs

Documentation versions (currently viewingVaadin 14)

You are viewing documentation for an older Vaadin version. View latest documentation

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.

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.

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.

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/.

HotswapAgent

To setup HotswapAgent follow the tutorial.

  • 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 or Eclipse.

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 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

06502FD1-DC4D-4DD1-9577-B1B9454A6FB2