How do I pull a spring bean manually? I have a rather large web application, and in a given service, a transient object requires access to a bean that is machine specific (database connection info.) Since the application runs in a cluster, this transient object (which can bounce between servers) always needs to grab the correct connection been from the current spring context and server.
So, what’s the best way to manually pull a bean out of spring?
You could have your service implement ApplicationContextAware so that you have access to the ApplicationContext itself and can call getBean() directly on it.