本文整理匯總了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()]));
}
}