Subject: Alternative to Spring Loaded for Hot Relo...
# questions
u
Subject: Alternative to Spring Loaded for Hot Reloading in Grails 6.2.1 with Java 17 and Gradle 7.6.4 Hello Community, I'm currently working on a Grails 6.2.1 project using Java 17 and Gradle 7.6.4. In my previous projects with Grails 5.3.5 and Java 7, I used Spring Loaded for hot reloading, which helped me reflect backend and frontend changes quickly. However, Spring Loaded is not compatible with Java 17. Currently, changes to both the backend and frontend are not reflecting as fast as I would like during development. I was wondering if there is an alternative to Spring Loaded that supports Java 17 and works effectively with Grails 6.2.1 and Gradle 7.6.4. Any suggestions or best practices for achieving fast reload times would be greatly appreciated! Thank you!
g
Unfortunately there is not such a replacement for Grails 6, but there is hope for Grails 7. I feel your pain cause I felt the same, now I kind of got used with Spring Dev Tools slower reload, but I would love to have the Spring Loaded experience back again.
u
is there any possible solution. at least to reduce some reloading time.🙂
j
Copy code
developmentOnly("org.springframework.boot:spring-boot-devtools")
is the best solution in Grails 6. HotSwap Agent in Grails 7 https://grails.slack.com/archives/C07LCNWHG/p1727404354990749
s
In Grails 6.x you can use JRebel but it will cost you..
💰 2
m
I’m not sure if it would help in your case, but here are some things we did back when Grails 3.3 came out which helped. Our general approach was to reduce start up time.
(I typed a long reply, but lost it when my phone ran out of battery, so I’ll post in parts now)
• disabled hbm2ddl (set dbCreate: none) on dev environment. We enable validation on test/prod (with CI) or manually when working on domains. • switched to Flyway to manage/version/initialize the DB with DDL using static SQL files, and some JDBC on Java for things that need a bit of programmatic behaviour (e.g. reading secrets from environment) Our DBA pointed out that we don’t need ORM or Transactions because our schema and data init is fairly deterministic, so using raw SQL helped a lot here. If you have data that needs to be loaded from some static files, read on. • Defer data/plugin initialization where possible and appropriate. • Let the developer easily enable/disable features/services at startup. If your app is small and simple, chances are the startup is fast. If the app is large enough, then maybe it would be helpful to disable some areas, so that a dev can focus on the thing being worked on. Some examples: • Loading data from files -> use a RPC or HTTP call that is only enabled on development • Connected services (MQ, S3, etc) -> only initialize the connection when the system first calls the methods. Sometimes plugins can slow down/complicate the startup, so it may be useful to just disable it at startup. A real example of this is Spring Security CAS Plugin which on top of needing the service to be online to let you log in, it also significantly increases the start up time. So we kept both S2 Core and S2 CAS configs on application.yml, and let the developer uncomment which one they want.
Before these changes we used to do a lot of test/sample data generation (which called business logic to set up) at Bootstrap.groovy, which made the startup take around 10-20 minutes. We didn’t prioritise it because the hot reloading really took the edge off during normal development. At some point, someone needed do something that needed a lot of restarts, so we started optimising for that.