I've got a service that registers JSON marshallers. I've added @PostConstruct
method that registers marshallers.
But my service it's not initialized because nobody uses it. I need to inject it to initialize it. Can I mark it to initialize on Grails startup? I can inject it into BootStrap.groovy but it's obvious why BootStrap.groovy do need it
Add a lazyInit
property
class MyService {
boolean lazyInit = false
@PostConstruct
void init() {
// this will now be executed at startup because the service is eagerly created
}
}
This property defaults to true
if omitted, so service beans are lazy by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With