Statically spilling your (Spring) Beans

Accessing Spring Beans from a static method

There are some edge cases where you want to access Spring Beans in a static method. While you should always try to refactor your code so you do not have to do this… this post will still show you how it can be done. Continue reading at your own risk! You have been warned! Autowiring Beans Getting instances of beans in Spring is pretty simple. You add @Autowired on your constructor and assuming your class is a bean as well, an instance will be injected in your constructor. [Read More]