0

I need the Spring boot application of mine to hot reload when a particular input file has changed. I have added the spring loaded plugin as shown below.

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>springloaded</artifactId>
                        <version>1.2.6.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

Then I am running the application as shown below.

mvn spring-boot:run -Drun.jvmArguments="-Dfilename=test/data/test.txt"

Application runs fine, but when I make changes to this test.txt, nothing is happening to the output. Hot reload is not happening. What am I doing wrong here? Is there anything else I need to do? Are there any better ways to achieve this? Any help would be much appreciated.

AnOldSoul
  • 4,017
  • 12
  • 57
  • 118

1 Answers1

0

From Spring Loaded documentation:

Spring Loaded is a JVM agent for reloading class file changes whilst a JVM is running.

You want stuff to happen based on that a text file that's not on the classpath has changed. It doesn't look like that's what Spring Loaded does.

There's another question regarding what I think you want: File changed listener in Java

Community
  • 1
  • 1
Buhb
  • 7,088
  • 3
  • 24
  • 38