1

I need to reinject a dependency once it is initialized w/o re-initializing of Application Context.

in detail below is what my requirement

if DB is down application should not perform any transaction , once DB is up application should resume.

this is what i am doing

i have created mongoTemplate , autowiring with attr (required=false). so that when application is getting deployed , even though DB is down ,deployment should not fail .

problem :::

but when DB will be up is there any way to reinitialize mongoTemplate and inject it again w/o rebooting server or re-deployment of application.

Bhupi
  • 387
  • 3
  • 16

1 Answers1

0

You should use a Provider for changing dependencies. See When to use javax.inject.Provider in Spring? for more information.

Community
  • 1
  • 1
Benoît
  • 1,080
  • 11
  • 28