Alternatives to @Autowire for static fields

Viewed 16330

What are alternatives to @Autowire for static fields?

I went through many questions and understood why @Autowired can't be used with static fields. The accepted answer of this question mentions

You'll have to write your own logic to do this., as @Autowired cannot be used.

As I am new to dependency injection, I did not get what steps would have to be followed to write our own logic to do this.

What I got is that new cannot be used to create the object as it would tightly couple the 2 classes and DI is meant to be a solution for it. Also using @autowired with setters is not recommended in the second answer of the same question. So what are the alternatives to achieve same effect without using @Autowire ?

4 Answers
Related