Description
Hello, I'm on Eclipse; I'm using an abstract class with a certain constructor, and if in a class extending that one I put @Autowired
on the constructor (that needs to call super(<arguments>)
inside), STS flags that annotation as unnecessary.
If I remove it, though, an exception is thrown: org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter <type and name of the parameter> in constructor <description of the constructor>
.
So, that annotation is for sure not unnecessary.
I don't know which class is responsible for this warning, but while I was looking for it I've noticed that the AutowiredConstructorReconciler class has a typo in it (says "Unnecesary", with one "s").
Here's a repo with a super simple project that reproduces the issue on STS 4.17.2.
The project contains two test classes: the abstract one whose constructor wants a RestTemplateBuilder
argument (I simply used the first @bean type that came to my mind, could be anything else); the other class extends it and has @Autowired
on the constructor.
If you try to execute the unit test, it will work. But if you remove that @Autowired
as the warning says, you'll get the exception I mentioned above.