简体   繁体   中英

Spring Autowiring at class initialization

Could the Autowiring using @Autowired spring annotation happen at class initialization, and not just before constructor call ? thanks for help

Ass described here: https://blog.jdriven.com/2015/03/spicy-spring-different-ways-of-autowiring/ :

Constructor Autowiring

Method Autowiring

with this ways of inject dependencies you have more control over the logic you want to apply during a bean initialization.

To elucidate on what rperes said, the InjectableBean is being injected at construction, but if you have not configured InjectableBean as a component to be injected, then you will have problems.

Check that your configuration for InjectableBean is correct. Have a look at Spring: Properly setup @ComponentScan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM