本文整理汇总了Java中org.springframework.context.annotation.AnnotationConfigApplicationContext.scan方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationConfigApplicationContext.scan方法的具体用法?Java AnnotationConfigApplicationContext.scan怎么用?Java AnnotationConfigApplicationContext.scan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.context.annotation.AnnotationConfigApplicationContext
的用法示例。
在下文中一共展示了AnnotationConfigApplicationContext.scan方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.springframework.context.annotation.AnnotationConfigApplicationContext; //导入方法依赖的package包/类
public static void main(String... args) throws IOException {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.scan(App.class.getPackage().getName());
applicationContext.refresh();
Spocker spocker = applicationContext.getBean(Spocker.class);
if (args.length != 2) {
throw new IllegalArgumentException("Source and output directory should be passed as arguments");
}
List<Path> paths = find(Paths.get(args[0]),
MAX_VALUE, (filePath, fileAttr) -> fileAttr.isRegularFile() && filePath.getFileName().toString().matches(".*\\.java"))
.collect(toList());
paths.stream().map(App::parse)
.filter(Optional::isPresent)
.map(Optional::get)
.map(spocker::toGroovyTypeModel)
.forEach(typeModel -> save(typeModel, args[1]));
}
示例2: init
import org.springframework.context.annotation.AnnotationConfigApplicationContext; //导入方法依赖的package包/类
@Override
public void init(String... packages) {
applicationContext = new AnnotationConfigApplicationContext();
Config config= DefaultConfig.INSTANCE;
ConfigBeanFactoryPostProcessor configBeanFactoryPostProcessor = new ConfigBeanFactoryPostProcessor(config);
applicationContext.addBeanFactoryPostProcessor(configBeanFactoryPostProcessor);
applicationContext.scan(packages);
}
示例3: testScanPackages
import org.springframework.context.annotation.AnnotationConfigApplicationContext; //导入方法依赖的package包/类
@Test
public void testScanPackages() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.scan("org.spring.springboot");
ctx.refresh();
assertEquals("message configuration", ctx.getBean("message"));
}
示例4: initialize
import org.springframework.context.annotation.AnnotationConfigApplicationContext; //导入方法依赖的package包/类
@Override
public void initialize(AnnotationConfigApplicationContext context) {
Set<String> packageNames = provider.getPackageNames(context.getEnvironment());
if (packageNames.size() > 0) {
LOG.info("Adding packageNames '{}' to component scan.", packageNames);
context.scan(packageNames.toArray(new String[packageNames.size()]));
}
}