static BeanDefinitionHolder applyScopedProxyMode( ScopeMetadata metadata, BeanDefinitionHolder definition, BeanDefinitionRegistry registry) { ScopedProxyMode scopedProxyMode = metadata.getScopedProxyMode(); if (scopedProxyMode.equals(ScopedProxyMode.NO)) { return definition; } boolean proxyTargetClass = scopedProxyMode.equals(ScopedProxyMode.TARGET_CLASS); return ScopedProxyCreator.createScopedProxy(definition, registry, proxyTargetClass); }
@Import(ConfigImportedWithSameSourceImportedInDifferentOrder.class) @PropertySources({ @PropertySource("classpath:org/springframework/context/annotation/p1.properties"), @PropertySource("classpath:org/springframework/context/annotation/p2.properties") }) @Configuration public static class ConfigWithSameSourceImportedInDifferentOrder { }
@Bean @Lazy public MyBean myBean() { return new MyBeanImpl(); } }
@Configuration @ComponentScan( basePackages = "org.springframework.context.annotation", useDefaultFilters = false, includeFilters = @Filter(type = FilterType.CUSTOM, classes = ComponentScanAnnotationIntegrationTests.AwareTypeFilter.class), lazyInit = true) class ComponentScanWithAwareTypeFilter {}
@Bean(name = "baz") @Conditional(AlwaysCondition.class) public ExampleBean baz1() { return new ExampleBean(); }
@Configuration @PropertySources({ @PropertySource("classpath:org/springframework/context/annotation/p1.properties"), @PropertySource("classpath:${base.package}/p2.properties"), }) static class ConfigWithPropertySources { }
@Configuration @Conditional(NeverMatchingCondition.class) @Import(BeanProvidingConfiguration.class) protected static class ConditionalConfiguration { }
@Configuration @Never @Import({ConfigurationNotCreated.class, RegistrarNotCreated.class, ImportSelectorNotCreated.class}) static class ImportsNotCreated { static { if (true) throw new RuntimeException(); } }
@Bean @Scope("prototype") public DependingFoo foo(BarArgument bar) { return new DependingFoo(bar); }
@Bean @Override default ServiceBean serviceBean() { return provider().getServiceBean(); } }
@Bean @Never public ExampleBean bean1() { return new ExampleBean(); } }
@Bean public String myString() { return factoryBean().getString(); } }
@Configuration @ComponentScan(basePackages = "example.scannable", scopedProxy = ScopedProxyMode.INTERFACES, useDefaultFilters = false, includeFilters = @Filter(type=FilterType.REGEX, pattern = "((?:[a-z.]+))ScopedProxyTestBean")) class ComponentScanWithScopedProxyThroughRegex {}
@Bean @Lazy public MyBean myBean() { return new MyBeanImpl(); }
@Bean(name = "baz") @Conditional(NeverCondition.class) public ExampleBean baz2() { return new ExampleBean(); } }
@Configuration @PropertySources({ @PropertySource(name = "psName", value = "classpath:org/springframework/context/annotation/p1.properties"), @PropertySource(name = "psName", value = "classpath:org/springframework/context/annotation/p2.properties"), }) static class ConfigWithNamedPropertySources { }
@Configuration @ComponentScan(basePackages = "example.scannable", useDefaultFilters = false, includeFilters = @Filter({CustomStereotype.class, CustomComponent.class}) ) class ComponentScanWithMultipleAnnotationIncludeFilters2 {}
@Bean @Lazy public static MyBean myBean() { return new MyBeanImpl(); }
@Override @Bean @Conditional(NeverCondition.class) public ExampleBean baz() { return new ExampleBean(); } }
@Configuration @PropertySources({ @PropertySource(name = "psName", value = "classpath:org/springframework/context/annotation/p1.properties"), @PropertySource(name = "psName", value = "classpath:org/springframework/context/annotation/missing.properties"), @PropertySource(name = "psName", value = "classpath:org/springframework/context/annotation/p2.properties") }) static class ConfigWithMissingPropertySource { }