and my both method having suppose 15 -15 injcetion . As we know post construct will get invoked only when all injcetion will get resolved . ? so means how it will work all 30 injection ll get resolved and then post constriuct method will be called ?
suppose i have to mek some 15 injection optiponal and 15 required . Then i HAVE TO PUT @REQUIRED with each injection ..there is not any gloabl way to do that
Solved! Go to Solution.
Why do you need to use 2 PostConstruct method. If you wanna split the logic, you can write in 2 months and both methods you can call inside @PostConstruct method.
E.g.
method1()
method2()
@PostConstruct
method init() {
method1()
method2()
}
Views
Replies
Total Likes
Hi,
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL - It will make all the injectors optional so if any injectors won't be able to get the value, it won't any error.
If you don't specifically define OPTIONAL and then in that case, you'll have to mark injectors as @Optional otherwise if it couldn't any value, then it'll throw error.
And, yes, @PostConstruct will be resolved once all the injectors are injected.
There's no other global way to handle the scenario. You'll have to use either one of approach.
Can we use two post construct method ?
Views
Replies
Total Likes
Why do you need to use 2 PostConstruct method. If you wanna split the logic, you can write in 2 months and both methods you can call inside @PostConstruct method.
E.g.
method1()
method2()
@PostConstruct
method init() {
method1()
method2()
}
Views
Replies
Total Likes
Views
Likes
Replies