Steven Schlansker opened SPR-14602 and commented
I have an @Configuration class which holds some internal configuration data. It wants to instantiate a collaborating @Configuration class, hand off some data to it, and expects its collaborator to exist. However, it seems that an @Bean method that returns a @Configuration class fails because its BeanDefinition#getBeanClassName is null, so ConfigurationClassUtils#checkConfigurationClassCandidate returns false.
@RunWith(SpringRunner.class)
@ContextConfiguration(classes=BeanDefinitionAutowireTest.Config.class)
public class BeanDefinitionAutowireTest {
@Configuration
public static class InnerConfig {
@Bean
URI someUri() {
return URI.create("/");
}
}
@Configuration
public static class Config {
@Bean
public InnerConfig innerConfig() {
return new InnerConfig();
}
}
@Autowired
URI someUri;
@Test
public void testUri() {
assertNotNull(someUri);
}
}
I feel that this should work. If for some reason it can not, it should throw an exception or otherwise fail obviously, rather than silently discarding the definitions you expect.
(Note that this test case is a little simplified, in the real case I pass constructor arguments to InnerConfig, so making things static is not an option)
Affects: 4.3.1
Issue Links:
Referenced from: commits 9b221f5, 6fe7e56
Steven Schlansker opened SPR-14602 and commented
I have an
@Configurationclass which holds some internal configuration data. It wants to instantiate a collaborating@Configurationclass, hand off some data to it, and expects its collaborator to exist. However, it seems that an@Beanmethod that returns a@Configurationclass fails because itsBeanDefinition#getBeanClassNameis null, soConfigurationClassUtils#checkConfigurationClassCandidatereturns false.I feel that this should work. If for some reason it can not, it should throw an exception or otherwise fail obviously, rather than silently discarding the definitions you expect.
(Note that this test case is a little simplified, in the real case I pass constructor arguments to
InnerConfig, so making things static is not an option)Affects: 4.3.1
Issue Links:
@Configurationimported via ImportBeanDefinitionRegistrar is not processed as configuration@Configurationimported via@ImportResourceis not processedReferenced from: commits 9b221f5, 6fe7e56