当前位置: 首页>>代码示例>>Java>>正文


Java MapperScannerConfigurer类代码示例

本文整理汇总了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;
}
 
开发者ID:zoeminghong,项目名称:pndaox,代码行数:8,代码来源:MyBatisConfig.java

示例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();
	}

}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:23,代码来源:MapperLoader.java

示例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();
	}

}
 
开发者ID:haogrgr,项目名称:haogrgr-test,代码行数:21,代码来源:XMLMapperLoader.java

示例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;
}
 
开发者ID:frankelau,项目名称:pndao,代码行数:8,代码来源:MyBatisConfig.java

示例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;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:11,代码来源:DeployerConfiguration.java

示例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);
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:8,代码来源:LocMybatisAutoConfiguration.java

示例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;
}
 
开发者ID:heikehuan,项目名称:background-template,代码行数:11,代码来源:MybatisConfiguration.java

示例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;
}
 
开发者ID:heikehuan,项目名称:huanhuan-blog,代码行数:11,代码来源:MybatisConfiguration.java

示例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;
}
 
开发者ID:mizukyf,项目名称:springboot-mybatis-mysample,代码行数:8,代码来源:SampleApplication.java

示例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;
}
 
开发者ID:moss0801,项目名称:apidoc,代码行数:9,代码来源:RootConfig.java

示例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;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:7,代码来源:DeployerConfiguration.java

示例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;
}
 
开发者ID:cwenao,项目名称:springboot_cwenao,代码行数:7,代码来源:DataConfig.java

示例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;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:80,代码来源:MyBatisConfigurationBuilder.java


注:本文中的org.mybatis.spring.mapper.MapperScannerConfigurer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。