本文整理汇总了Java中org.mybatis.spring.mapper.MapperScannerConfigurer类的典型用法代码示例。如果您正苦于以下问题:Java MapperScannerConfigurer类的具体用法?Java MapperScannerConfigurer怎么用?Java MapperScannerConfigurer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapperScannerConfigurer类属于org.mybatis.spring.mapper包,在下文中一共展示了MapperScannerConfigurer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer configurer = new MapperScannerConfigurer();
configurer.setBasePackage("com.trc.**.dao");
configurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
return configurer;
}
示例2: afterPropertiesSet
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
try {
service = Executors.newScheduledThreadPool(1);
// 获取xml所在包
MapperScannerConfigurer config = context.getBean(MapperScannerConfigurer.class);
Field field = config.getClass().getDeclaredField("basePackage");
field.setAccessible(true);
basePackage = (String) field.get(config);
// 触发文件监听事件
scanner = new Scanner();
scanner.scan();
service.scheduleAtFixedRate(new Task(), 5, 5, TimeUnit.SECONDS);
} catch (Exception e1) {
e1.printStackTrace();
}
}
示例3: afterPropertiesSet
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
try {
service = Executors.newScheduledThreadPool(1);
// 获取xml所在包
MapperScannerConfigurer config = context.getBean(MapperScannerConfigurer.class);
Field field = config.getClass().getDeclaredField("basePackage");
field.setAccessible(true);
basePackage = (String) field.get(config);
// 触发文件监听事件
scanner = new Scanner();
scanner.scan();
service.scheduleAtFixedRate(new Task(), 5, 5, TimeUnit.SECONDS);
} catch (Exception e1) {
e1.printStackTrace();
}
}
示例4: mapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer configurer = new MapperScannerConfigurer();
configurer.setBasePackage("com.piaoniu.**.dao");
configurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
return configurer;
}
示例5: getWoProvider
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Bean
public CmsWoProvider getWoProvider(MapperScannerConfigurer mapperScannerConfigurer,
DJMapper djMapper, DJDpmtMapper djDpmtMapper, CmsCmRfcMrgProcessor rfcProcessor) {
CmsWoProvider woProvider = new CmsWoProvider();
woProvider.setDjMapper(djMapper);
woProvider.setDpmtMapper(djDpmtMapper);
woProvider.setCmsUtil(new CmsUtil());
woProvider.setCmrfcProcessor(rfcProcessor);
return woProvider;
}
示例6: createBasePackageScanner
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
private void createBasePackageScanner(BeanDefinitionRegistry registry, String basePackage,
String prefixName) {
MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
scannerConfigurer.setBasePackage(basePackage);
scannerConfigurer.setSqlSessionFactoryBeanName(prefixName + "SessionFactory");
scannerConfigurer.postProcessBeanDefinitionRegistry(registry);
}
示例7: mapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
/**
* 扫描跑mapper包下的所有接口,作为mybatis接口类,并注册为spring的bean
*/
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
scannerConfigurer.setAddToConfig(true);
scannerConfigurer.setBasePackage("com.template.**.mapper");
return scannerConfigurer;
}
示例8: mapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
/**
* 扫描跑mapper包下的所有接口,作为mybatis接口类,并注册为spring的bean
*/
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
scannerConfigurer.setAddToConfig(true);
scannerConfigurer.setBasePackage("com.huan.**.mapper");
return scannerConfigurer;
}
示例9: mapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() throws Exception {
final MapperScannerConfigurer msc = new MapperScannerConfigurer();
msc.setBasePackage(MAPPER_SCAN_BASE_PACKAGE);
msc.afterPropertiesSet();
return msc;
}
示例10: apiMapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Bean
public MapperScannerConfigurer apiMapperScannerConfigurer() throws Exception {
MapperScannerConfigurer mapperScannerConfigurer =
new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage("com.moss.apidoc.repository");
mapperScannerConfigurer.setSqlSessionFactoryBeanName("apiSqlSessionFactory");
return mapperScannerConfigurer;
}
示例11: getMapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Bean
public MapperScannerConfigurer getMapperScannerConfigurer() {
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage("com.oneops.cms.dj.dal");
return mapperScannerConfigurer;
}
示例12: mapperScannerConfigurer
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer bean = new MapperScannerConfigurer();
bean.setBasePackage("com.bootcwenao.esserver.mapper");
return bean;
}
示例13: findMyBatisBeanDefinitions
import org.mybatis.spring.mapper.MapperScannerConfigurer; //导入依赖的package包/类
private Map<String, BeanDefinition> findMyBatisBeanDefinitions() {
String[] enumsLocations = attributes.getStringArray(Constant.ENUMS_LOCATIONS_ATTRIBUTE_NAME);
String[] basePackages = attributes.getStringArray(Constant.BASE_PACKAGES_ATTRIBUTE_NAME);
AnnotationAttributes[] plugins = attributes.getAnnotationArray(Constant.PLUGINS_ATTRIBUTE_NAME);
if (ArrayUtils.isEmpty(enumsLocations)) {
enumsLocations = findDefaultPackage(metadata);
}
if (ArrayUtils.isEmpty(basePackages)) {
basePackages = findDefaultPackage(metadata);
}
Map<String, BeanDefinition> beanDefinitions = new HashMap<>(16);
BeanDefinitionBuilder sqlSessionFactoryBean = BeanDefinitionBuilder.genericBeanDefinition(SqlSessionFactoryBean.class);
if (useFlyway) {
sqlSessionFactoryBean.addDependsOn(Constant.FLYWAY_BEAN_NAME);
}
sqlSessionFactoryBean.addPropertyReference("dataSource", Constant.DATA_SOURCE_BEAN_NAME);
sqlSessionFactoryBean.addPropertyValue("mapperLocations", "classpath*:/META-INF/mybatis/**/*Mapper.xml");
sqlSessionFactoryBean.addPropertyValue("configLocation", "classpath:/META-INF/mybatis/mybatis.xml");
TypeHandlerScanner scanner = new TypeHandlerScanner();
sqlSessionFactoryBean.addPropertyValue("typeHandlers", scanner.find(StringUtils.join(enumsLocations, ",")));
List<Interceptor> pluginsList = new ArrayList<>(plugins.length);
List<Class<? extends Interceptor>> clazz = new ArrayList<>(plugins.length);
for (AnnotationAttributes plugin : plugins) {
Class<? extends Interceptor> pluginClass = plugin.getClass("value");
AnnotationAttributes[] params = plugin.getAnnotationArray("params");
clazz.add(pluginClass);
Interceptor interceptor = BeanUtils.instantiate(pluginClass);
BeanWrapper beanWrapper = new BeanWrapperImpl(interceptor);
for (AnnotationAttributes param : params) {
String key = param.getString("key");
String value = param.getString("value");
PropertyDescriptor descriptor = beanWrapper.getPropertyDescriptor(key);
Method writeMethod = descriptor.getWriteMethod();
Method readMethod = descriptor.getReadMethod();
writeMethod.setAccessible(true);
try {
Class<?> returnType = readMethod.getReturnType();
Object valueObject = value;
if (Integer.class.equals(returnType) || int.class.equals(returnType)) {
valueObject = Integer.valueOf(value);
} else if (Long.class.equals(returnType) || long.class.equals(returnType)) {
valueObject = Long.valueOf(value);
} else if (Boolean.class.equals(returnType) || boolean.class.equals(returnType)) {
valueObject = Boolean.valueOf(value);
} else if (Double.class.equals(returnType) || double.class.equals(returnType)) {
valueObject = Double.valueOf(value);
}
writeMethod.invoke(interceptor, valueObject);
} catch (Exception e) {
e.printStackTrace();
}
}
pluginsList.add(interceptor);
}
if (!clazz.contains(PaginationInterceptor.class)) {
pluginsList.add(BeanUtils.instantiate(PaginationInterceptor.class));
}
sqlSessionFactoryBean.addPropertyValue("plugins", pluginsList);
BeanDefinitionBuilder scannerConfigurerBean = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);
scannerConfigurerBean.addPropertyValue("basePackage", StringUtils.join(basePackages, ","));
scannerConfigurerBean.addPropertyValue("annotationClass", Repository.class);
scannerConfigurerBean.addPropertyValue("sqlSessionFactoryBeanName", "sqlSessionFactory");
beanDefinitions.put("sqlSessionFactory", sqlSessionFactoryBean.getBeanDefinition());
beanDefinitions.put("mapperScannerConfigurer", scannerConfigurerBean.getBeanDefinition());
return beanDefinitions;
}