Affects: spring 5.3 (specifically; spring boot 2.6.6)
Sorry, I realize this is a report for an old version, but maybe this is still relevant in newer versions because google wasn't of much help to me
After changing CI server to build on linux with docker, spring boot app started to undeterministically fail with NoSuchBeanDefinitionException. Ie, it works half the time (and it used to work all the time when the jar was being built on windows). I tracked it down and I think the cause was probably this:
@Service
public class Foo {
@Autowired public void setBar(BarImpl bar) { ... }
}
@Configuration
public class Config {
@Bean
public Bar makeBar() {
return new BarImpl();
}
}
ie., a bean is registered through interface type, and autowired through implementation type. I think this is the cause, because I stepped through wiring internals with debugger, and I found container rejecting makeBar bean due to barImplType.isAssignableFrom(barType) yielding false (where type is ResolvedType instance).
This is bad code, but regardless if it should or shouldn't work, it should behave more deterministically.
Affects: spring 5.3 (specifically; spring boot 2.6.6)
Sorry, I realize this is a report for an old version, but maybe this is still relevant in newer versions because google wasn't of much help to me
After changing CI server to build on linux with docker, spring boot app started to undeterministically fail with NoSuchBeanDefinitionException. Ie, it works half the time (and it used to work all the time when the jar was being built on windows). I tracked it down and I think the cause was probably this:
ie., a bean is registered through interface type, and autowired through implementation type. I think this is the cause, because I stepped through wiring internals with debugger, and I found container rejecting makeBar bean due to
barImplType.isAssignableFrom(barType)yielding false (where type is ResolvedType instance).This is bad code, but regardless if it should or shouldn't work, it should behave more deterministically.