3 ms·
Spring is perfectly usable without `@Autowired`, at least outside of test classes. SonarQube has a rule that helps avoiding it. Just use constructor injection i
by samus 2y ago
Spring is perfectly usable without `@Autowired`, at least outside of test classes. SonarQube has a rule that helps avoiding it. Just use constructor injection instead.
- fiddlerwoaroof 2y agoAny form of dependency injection by classpath scanning is an antifeature
- samus 2y agoClasspath scanning is completely optional.
- Clamchop 2y agoConstructor injection is still autowiring. Spring used to demand that you annotate constructor arguments with @Autowired but that changed some time ago.
- samus 2y agoNo, it's the only sane technique to do dependency injection. And it still doesn't force you to do autowiring; you can also write a @Bean factory method for all components in the application if you really want.