本文整理了Java中org.springframework.context.annotation.Import.<init>()
方法的一些代码示例,展示了Import.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Import.<init>()
方法的具体详情如下:
包路径:org.springframework.context.annotation.Import
类名称:Import
方法名:<init>
暂无
代码示例来源:origin: baomidou/mybatis-plus
/**
* {@link org.mybatis.spring.annotation.MapperScan} ultimately ends up
* creating instances of {@link MapperFactoryBean}. If
* {@link org.mybatis.spring.annotation.MapperScan} is used then this
* auto-configuration is not needed. If it is _not_ used, however, then this
* will bring in a bean registrar and automatically register components based
* on the same component-scanning path as Spring Boot itself.
*/
@Configuration
@Import({AutoConfiguredMapperScannerRegistrar.class})
@ConditionalOnMissingBean(MapperFactoryBean.class)
public static class MapperScannerRegistrarNotFoundConfiguration implements InitializingBean {
@Override
public void afterPropertiesSet() {
logger.debug("No {} found.", MapperFactoryBean.class.getName());
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(TestBean.class)
static class ConfigThatImportsNonConfigClass {
@Autowired TestBean testBean;
}
代码示例来源:origin: spring-cloud/spring-cloud-config
@EnableConfigurationProperties(ConfigServerProperties.class)
@Import({ EnvironmentRepositoryConfiguration.class })
protected static class LocalPropertySourceLocatorConfiguration {
@Autowired
private EnvironmentRepository repository;
@Autowired
private ConfigClientProperties client;
@Autowired
private ConfigServerProperties server;
@Bean
public EnvironmentRepositoryPropertySourceLocator environmentRepositoryPropertySourceLocator() {
return new EnvironmentRepositoryPropertySourceLocator(this.repository, this.client.getName(),
this.client.getProfile(), getDefaultLabel());
}
private String getDefaultLabel() {
if (StringUtils.hasText(this.client.getLabel())) {
return this.client.getLabel();
} else if (StringUtils.hasText(this.server.getDefaultLabel())) {
return this.server.getDefaultLabel();
}
return null;
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(B.class)
static class A {
@Bean
TestBean b1() {
return new TestBean();
}
}
代码示例来源:origin: citerus/dddsample-core
@Configuration
@Import({DDDSampleApplicationContext.class,
PathfinderApplicationContext.class})
@EnableAutoConfiguration
public class Application {
@Autowired
SampleDataGenerator sampleDataGenerator;
@PostConstruct
public void init() {
sampleDataGenerator.generate();
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(A.class)
static class B {
@Bean
TestBean b2() {
return new TestBean();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(NameConfig.class)
static class AutowiredConfig {
@Autowired String autowiredName;
@Bean TestBean testBean() {
TestBean testBean = new TestBean();
testBean.name = autowiredName;
return testBean;
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import({Y.class, Z.class})
class X {
@Bean
TestBean x() {
return new TestBean();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import({ConditionalConfiguration.class, UnconditionalConfiguration.class})
protected static class ConditionalThenUnconditional {
@Autowired
private BeanOne beanOne;
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(SubConfig.class)
static class ShadowConfig {
@Bean
String aString() {
return "shadow";
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import({UnconditionalConfiguration.class, ConditionalConfiguration.class})
protected static class UnconditionalThenConditional {
@Autowired
private BeanOne beanOne;
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration("outer")
@Import(C.class)
static class A {
@Component("nested")
static class B {
@Bean public String nestedBean() { return ""; }
}
}
代码示例来源:origin: spring-cloud/spring-cloud-sleuth
/**
* MVC Adapter that adds the {@link SpanCustomizingAsyncHandlerInterceptor}
*
* @author Marcin Grzejszczak
* @since 1.0.3
*/
@Configuration
@Import(SpanCustomizingAsyncHandlerInterceptor.class)
class TraceWebMvcConfigurer implements WebMvcConfigurer {
@Autowired
ApplicationContext applicationContext;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(this.applicationContext
.getBean(SpanCustomizingAsyncHandlerInterceptor.class));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(SecondLevel.class)
static class FirstLevel {
@Bean
public TestBean m() {
return new TestBean();
}
}
代码示例来源:origin: spring-cloud/spring-cloud-kubernetes
@Configuration
@Import(KubernetesAutoConfiguration.class)
@EnableConfigurationProperties({ ConfigMapConfigProperties.class,
SecretsConfigProperties.class })
protected static class KubernetesPropertySourceConfiguration {
@Autowired
private KubernetesClient client;
@Bean
@ConditionalOnProperty(name = "spring.cloud.kubernetes.config.enabled", matchIfMissing = true)
public ConfigMapPropertySourceLocator configMapPropertySourceLocator(
ConfigMapConfigProperties properties) {
return new ConfigMapPropertySourceLocator(client, properties);
}
@Bean
@ConditionalOnProperty(name = "spring.cloud.kubernetes.secrets.enabled", matchIfMissing = true)
public SecretsPropertySourceLocator secretsPropertySourceLocator(
SecretsConfigProperties properties) {
return new SecretsPropertySourceLocator(client, properties);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import({Z1.class, Z2.class})
class Z {
@Bean
TestBean z() {
return new TestBean();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(FooConfig.class)
@EnableCaching
static class BeanConditionConfig {
@Autowired
Environment env;
@Bean
public Bar bar() {
return new Bar(Boolean.valueOf(env.getProperty("bar.enabled")));
}
static class Bar {
public int count;
private final boolean enabled;
public Bar(boolean enabled) {
this.enabled = enabled;
}
public boolean isEnabled() {
this.count++;
return this.enabled;
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(Z.class)
class Z2 {
@Bean
TestBean z2() {
return new TestBean();
}
}
代码示例来源:origin: spring-projects/spring-data-examples
@Configuration
@EnableJdbcRepositories
@Import(JdbcConfiguration.class)
public class CategoryConfiguration {
@Autowired private DataSource dataSource;
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(OtherConfiguration.class)
static class ConfigurationWithImportAnnotation {
@Bean
public ITestBean one() {
return new TestBean();
}
}
内容来源于网络,如有侵权,请联系作者删除!