Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto reload spring boot application in docker using spring dev tools

I followed this link to deploy my application into local docker directly and debug it. I was able to deploy and debug but auto reload was not working for me Can you help me with auto reload for dockers using spring dev tools

The reason I am interested in doing it this way because my application talks to 5 different services and running them individually might be little difficult. So will be hosting them individually on the docker.

My trouble here is as of now I have to kill the container, then remove it and then add the new one back and I have to do this each time I change something

I am using Spring Boot 1.4 | IntelliJ | Docker and spring dev tools

like image 349
Anunay Avatar asked Oct 17 '16 16:10

Anunay


People also ask

Does spring boot have live reload?

By default for Vaadin applications based on Spring Boot, live reload uses Spring Boot Developer Tools to automatically restart the server whenever classpath entries are updated. The restart is faster than a manual restart, as it uses a customized class loader that reloads only the application's own classes.

How do I enable auto reload of my spring boot Mcq?

26) How can you enable auto reload of application with Spring Boot? You can enable auto-reload/LiveReload of spring boot application by adding the spring-boot-devtools dependency in the pom. xml file.


2 Answers

You should add new Run/Debug configuration and select RemoteSpringApplication as a Main class. Also you should set Program arguments as ip address to your service (ex. http://localhost:8080). Also add spring.devtools.remote.secret: mysecret into your application properties.
My configuration: enter image description here

http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#_running_the_remote_client_application

Spring boot has bug with RemoteSpringApplication which do not allows to remove or add new class. This will be fixed in Spring Boot 1.4.3 https://github.com/spring-projects/spring-boot/issues/7379

like image 193
PawelN Avatar answered Sep 17 '22 21:09

PawelN


Also, try to add this plugin:

./pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <excludeDevtools>false</excludeDevtools>
            </configuration>
        </plugin>
    </plugins>
</build>
like image 24
Ivan Avatar answered Sep 20 '22 21:09

Ivan