javaspringstaticautowired

Can you use @Autowired with static fields?


Is there some way to use @Autowired with the static fields? If not, are there some other ways to do this?


Solution

  • In short, no. You cannot autowire or manually wire static fields in Spring. You'll have to write your own logic to do this.