spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.57k stars 40.55k forks source link

Add a property for configuring additional livereload paths #40342

Open 30atm opened 5 months ago

30atm commented 5 months ago

Thymeleaf allows using files from src folder during development. However live reload does not have a file system watcher for "additional paths" to auto reload based on those templates

Just as there is there is spring.devtools.restart.additional-paths,

request new property spring.devtools.livereload.additional-paths

this should work in support of thymeleaf.prefix

logging:
  config: classpath:log4j2-local.xml
spring:
  devtools:
    livereload:
      enabled: 'true'
      additional-paths:
        - file:src/main/resources/static/
        - file:src/main/resources/templates/
  thymeleaf:
    cache: 'false'
    prefix: file:src/main/resources/templates/
    check-template-location: 'true'

  web:
    resources:
      static-locations:
        - file:src/main/resources/static/
        - classpath:/static/
      cache:
        period: 0
mhalbritter commented 5 months ago

I think this is already possible, but it's somewhat non-intuitive:

Add the additional paths to spring.devtools.restart.additional-paths but then exclude them from restarting the application through spring.devtools.restart.additional-exclude.

This should set the filewatcher to watch for changes, triggering the livereload, but don't restart the app as the location has been excluded from restart.

But I agree that there should be a property for that.

itsAkshayDubey commented 4 months ago

Hi @mhalbritter ,

I would like to work on this enhancement, could you please assign me this issue so that I can submit my PR in favour of this issue.

Thanks, Akshay

philwebb commented 4 months ago

All yours @itsAkshayDubey

30atm commented 4 months ago

I used a work-around and achieved this behavior

see LiveReloadConfig.java in this repo https://github.com/ibhatech/world-facts/tree/dev

itsAkshayDubey commented 4 months ago

Unable to access this repo. @metaforte

30atm commented 4 months ago

made it public now

itsAkshayDubey commented 2 months ago

Hi @philwebb ,

Kindly have a look at PR #41566

Thanks, Akshay