News for hackers. Stuff that matters.
Re:Java 24 by Clamchop on Tuesday March 18, 2025 @06:28PM (#43405920)
> avoid ugly things like Spring's autowiring of dependencies.

This seems awfully close to "avoid Spring" to me, heh.

Though, I've grown rather fond of Spring Boot over time, but I've gathered that's not exactly the popular consensus.

Re:Java 24 by fiddlerwoaroof on Tuesday March 18, 2025 @11:31PM (#43408047)
> This seems awfully close to "avoid Spring" to me, heh.

Exactly :)

Re:Java 24 by samus on Wednesday March 19, 2025 @06:36AM (#43410239)
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.
Re:Java 24 by fiddlerwoaroof on Wednesday March 19, 2025 @09:12PM (#43418994)
Any form of dependency injection by classpath scanning is an antifeature
Re:Java 24 by samus on Friday March 21, 2025 @02:53AM (#43432528)
Classpath scanning is completely optional.
Re:Java 24 by Clamchop on Thursday March 20, 2025 @03:22PM (#43427735)
Constructor injection is still autowiring. Spring used to demand that you annotate constructor arguments with @Autowired but that changed some time ago.
Re:Java 24 by samus on Friday March 21, 2025 @02:58AM (#43432547)
No, 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.