本文整理了Java中org.springframework.context.annotation.Import
类的一些代码示例,展示了Import
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Import
类的具体详情如下:
包路径:org.springframework.context.annotation.Import
类名称:Import
暂无
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(TestBean.class)
static class ConfigThatImportsNonConfigClass {
@Autowired TestBean 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-data-book
/**
* JavaConfig class to activate component scanning to pick up
* {@link com.oreilly.springdata.jpa.core.JpaCustomerRepository}. Re-uses the common infrastructure configuration
* defined in {@link InfrastructureConfig}.
*
* @author Oliver Gierke
*/
@Configuration
@ComponentScan(basePackageClasses = Customer.class)
@Import(InfrastructureConfig.class)
public class PlainJpaConfig {
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(B.class)
static class A {
@Bean
TestBean b1() {
return new TestBean();
}
}
代码示例来源:origin: blox/blox
@Configuration
@Import(MapperConfiguration.class)
@ComponentScan(
basePackages = {"com.amazonaws.blox.frontend.operations", "com.amazonaws.blox.frontend.exception"}
public class IntegrationTestConfig {
@Autowired private ConfigurableWebApplicationContext applicationContext;
代码示例来源:origin: spring-cloud/spring-cloud-config
/**
* @author Spencer Gibb
*/
@Configuration
@ConditionalOnBean(ConfigServerConfiguration.Marker.class)
@EnableConfigurationProperties(ConfigServerProperties.class)
@Import({ EnvironmentRepositoryConfiguration.class, CompositeConfiguration.class, ResourceRepositoryConfiguration.class,
ConfigServerEncryptionConfiguration.class, ConfigServerMvcConfiguration.class })
public class ConfigServerAutoConfiguration {
}
代码示例来源: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-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-cloud/spring-cloud-sleuth
/**
* Nested config that configures Web MVC if it's present (without adding a runtime
* dependency to it).
*/
@Configuration
@ConditionalOnClass(WebMvcConfigurer.class)
@Import(TraceWebMvcConfigurer.class)
protected static class TraceWebMvcAutoConfiguration {
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@SpringBootTest(classes = {AdminApplication.class})
@TestPropertySource(locations = "classpath:/config/bc/overrideprops/admin_springboot_testoverrides.properties")
@Import(AdminSpringBootTestConfiguration.class)
public abstract class JUnitSpringBootAdminIntegrationSetup {
@Autowired
@Qualifier("blRequestContextFilter")
private RequestContextFilter requestContextFilter;
@Autowired
@Qualifier("openEntityManagerInViewFilter")
private OpenEntityManagerInViewFilter openEntityManagerInViewFilter;
@Autowired
private TestAdminRequestFilter adminRequestFilter;
代码示例来源:origin: Dromara/soul
/**
* soul admin start.
*
* @author xiaoyu(Myth)
*/
@SpringBootApplication
@ComponentScan("org.dromara.soul")
@Import(value = {ZookeeperConfiguration.class})
public class SoulAdminApplication {
/**
* Main Entrance.
*
* @param args startup arguments
*/
public static void main(final String[] args) {
SpringApplication.run(SoulAdminApplication.class, args);
}
}
代码示例来源:origin: org.springframework.boot/spring-boot-test
private Class<?>[] getImports(Annotation annotation) {
if (annotation instanceof Import) {
return ((Import) annotation).value();
}
return NO_IMPORTS;
}
代码示例来源:origin: line/armeria
/**
* An auto-configuration for Armeria-based {@link WebClient}.
*/
@Configuration
@ConditionalOnClass(WebClient.Builder.class)
@ConditionalOnMissingBean(ClientHttpConnector.class)
@Import({ WebClientAutoConfiguration.class, DataBufferFactoryWrapperConfiguration.class })
public class ArmeriaClientAutoConfiguration {
/**
* Returns a {@link ClientHttpConnector} which is configured by a list of
* {@link ArmeriaClientConfigurator}s.
*/
@Bean
public ClientHttpConnector clientHttpConnector(
List<ArmeriaClientConfigurator> customizer,
DataBufferFactoryWrapper<?> factoryWrapper) {
return new ArmeriaClientHttpConnector(customizer, factoryWrapper);
}
/**
* Returns a {@link WebClientCustomizer} which sets an {@link ArmeriaClientHttpConnector} to the
* {@link Builder}.
*/
@Bean
public WebClientCustomizer webClientCustomizer(ClientHttpConnector clientHttpConnector) {
return builder -> builder.clientConnector(clientHttpConnector);
}
}
代码示例来源:origin: shopizer-ecommerce/shopizer
@Configuration
@EnableAutoConfiguration
/**
* added in shopizer-core-config.xml
*
* @author c.samson
*
*/
@ComponentScan({"com.salesmanager.core.business"})
@ImportResource("classpath:/spring/shopizer-core-context.xml")
@Import(DroolsConfiguration.class)
public class CoreApplicationConfiguration {
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(A.class)
static class B {
@Bean
TestBean b2() {
return new TestBean();
}
}
代码示例来源:origin: spring-projects/spring-data-rest
@Configuration
@EnableHypermediaSupport(type = HypermediaType.HAL)
@ComponentScan(basePackageClasses = RepositoryRestController.class,
includeFilters = @Filter(BasePathAwareController.class), useDefaultFilters = false)
@ImportResource("classpath*:META-INF/spring-data-rest/**/*.xml")
@Import({ SpringDataJacksonConfiguration.class, EnableSpringDataWebSupport.QuerydslActivator.class })
public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebConfiguration
implements InitializingBean, BeanClassLoaderAware {
RepositoryRestMvcConfiguration.class.getClassLoader());
@Autowired ApplicationContext applicationContext;
@Autowired(required = false) List<BackendIdConverter> idConverters = Collections.emptyList();
@Autowired(required = false) List<RepositoryRestConfigurer> configurers = Collections.emptyList();
@Autowired(required = false) List<EntityLookup<?>> lookups = Collections.emptyList();
代码示例来源:origin: codecentric/spring-boot-admin
@Configuration
@ConditionalOnBean(AdminServerMarkerConfiguration.Marker.class)
@EnableConfigurationProperties(AdminServerProperties.class)
@Import({AdminServerWebConfiguration.class})
public class AdminServerAutoConfiguration {
private final AdminServerProperties adminServerProperties;
代码示例来源:origin: abel533/Mapper
/**
* {@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.
*/
@org.springframework.context.annotation.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: AxonFramework/AxonFramework
@ConditionalOnClass(SpringAxonAutoConfigurer.class)
@AutoConfigureAfter({
AxonAutoConfiguration.class,
JpaAutoConfiguration.class,
JpaEventStoreAutoConfiguration.class,
NoOpTransactionAutoConfiguration.class,
TransactionAutoConfiguration.class})
@Import(SpringAxonAutoConfigurer.ImportSelector.class)
@AnnotationDriven
@Configuration
public class InfraConfiguration {
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!