- Start the spring boot app
grails-lazy-issue
via./gradlew bootRun
- Notice the bean wiring output is logged during boot time
The lazy beans are being eagerly loaded.
Stop application and uncomment resources.groovy code and restart.
fooService(FooService){ bean ->
bean.lazyInit = true
}
The bean is now loaded lazily, but only because the service bean is lazy loaded.
Adding the following causes the bean to still be eagerly loaded
sampleBean(SampleBean){ bean ->
bean.lazyInit = true
}
- Start the spring boot app
spring-boot-lazy
via./gradlew bootRun
- Hit endpoint
http://localhost:8080/index
notice the output is clean - Hit endpoint
http://localhost:8080/foo/index
notice the bean wiring output is logged
The lazy wiring worked as expected