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


Java SqlSessionFactoryBean.setMapperLocations方法代码示例

本文整理汇总了Java中org.mybatis.spring.SqlSessionFactoryBean.setMapperLocations方法的典型用法代码示例。如果您正苦于以下问题:Java SqlSessionFactoryBean.setMapperLocations方法的具体用法?Java SqlSessionFactoryBean.setMapperLocations怎么用?Java SqlSessionFactoryBean.setMapperLocations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mybatis.spring.SqlSessionFactoryBean的用法示例。


在下文中一共展示了SqlSessionFactoryBean.setMapperLocations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Primary
@Bean(name = "test1dbSqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("test1db") DataSource dataSource) throws Exception {
    SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setTypeAliasesPackage("com.maxplus1.demo.entity");
    factoryBean.setMapperLocations(
            new PathMatchingResourcePatternResolver().getResources("classpath:mapper/test1db/*.xml"));
    return factoryBean.getObject();
}
 
开发者ID:Paleozoic,项目名称:storm_spring_boot_demo,代码行数:11,代码来源:Test1dbConfig.java

示例2: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource) throws IOException {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();

    //mybatis配置
    Properties prop = new Properties();
    prop.setProperty("mapUnderscoreToCamelCase", "true");

    sqlSessionFactoryBean.setConfigurationProperties(prop);
    sqlSessionFactoryBean.setTypeAliasesPackage("com.tc.ly.bean");

    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Resource[] resources = resolver.getResources("classpath:mapper/*.xml");

    sqlSessionFactoryBean.setMapperLocations(resources);
    sqlSessionFactoryBean.setDataSource(dataSource);

    return sqlSessionFactoryBean;
}
 
开发者ID:hadesvip,项目名称:ly-security,代码行数:20,代码来源:MybatisConfig.java

示例3: SqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean(name = "sqlSessionFactory")
    @Primary
    public SqlSessionFactory SqlSessionFactory(@Qualifier("datasource") DataSource dataSource
            , ApplicationContext applicationContext) throws Exception {
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();

        // accur Could not resolve type alias in running jar
        sqlSessionFactoryBean.setVfs(SpringBootVFS.class);

        sqlSessionFactoryBean.setDataSource(dataSource);
        sqlSessionFactoryBean.setMapperLocations(
                applicationContext.getResources("classpath:META-INF/mappers/*.xml")
        );
        sqlSessionFactoryBean.setConfigLocation(
                applicationContext.getResource("classpath:META-INF/mybatis-config.xml")
        );
//        sqlSessionFactoryBean.setConfigurationProperties(mybatisProperties());
        sqlSessionFactoryBean.setTypeAliasesPackage("com.pineone.icbms.so.interfaces.database.model");

        return sqlSessionFactoryBean.getObject();
    }
 
开发者ID:iotoasis,项目名称:SO,代码行数:22,代码来源:DatabaseConfig.java

示例4: sqlSessionFactoryBean

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactoryBean sqlSessionFactoryBean(
        DataSource dataSource,
        ApplicationContext applicationContext) throws IOException {

    SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();

    // 마이바티스가 사용한 DataSource를 등록
    factoryBean.setDataSource(dataSource);

    // 마이바티스 설정파일 위치 설정
    factoryBean.setConfigLocation(applicationContext.getResource("classpath:mybatis-config.xml"));
    factoryBean.setMapperLocations(applicationContext.getResources("classpath:net/andromedarabbit/persistence/mybatis/**/*.xml"));

    factoryBean.setPlugins(new Interceptor[]{
            new PaginationInterceptor(),
            new PaginationResultSetHandlerInterceptor()
    });

    return factoryBean;
}
 
开发者ID:andromedarabbit,项目名称:mybatis-pagination,代码行数:22,代码来源:MyBatisConfig.java

示例5: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory() throws Exception {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(roundRobinDataSouceProxy());
    sqlSessionFactoryBean.setTypeAliasesPackage(this.typeAliasesPackage);
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources(this.mapperLocations));
    sqlSessionFactoryBean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
    return sqlSessionFactoryBean.getObject();
}
 
开发者ID:jinping125,项目名称:read-write-sever,代码行数:12,代码来源:MybatisConfig.java

示例6: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
 * 根据数据源创建SqlSessionFactory
 */
@Bean
public SqlSessionFactory sqlSessionFactory(AbstractRoutingDataSource routingDataSource) throws Exception {
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
    factoryBean.setDataSource(routingDataSource);// 指定数据源(这个必须有,否则报错)
    // 下边两句仅仅用于*.xml文件,如果整个持久层操作不需要使用到xml文件的话(只用注解就可以搞定),则不加
    factoryBean.setTypeAliasesPackage("com.tangcheng.datasources.aop.model");// 指定基包
    factoryBean.setMapperLocations(resolver.getResources("classpath:mapper/**/*.xml"));//
    return factoryBean.getObject();
}
 
开发者ID:helloworldtang,项目名称:springboot-multi-datasource,代码行数:14,代码来源:MyBatisConfig.java

示例7: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSource());
    //mybatis分页
    PageHelper pageHelper = new PageHelper();
    Properties props = new Properties();
    props.setProperty("dialect", "mysql");
    props.setProperty("reasonable", "true");
    props.setProperty("supportMethodsArguments", "true");
    props.setProperty("returnPageInfo", "check");
    props.setProperty("params", "count=countSql");
    pageHelper.setProperties(props); //添加插件
    sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:org/xxpay/dal/dao/mapper/*.xml"));
    return sqlSessionFactoryBean.getObject();
}
 
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:19,代码来源:DruidDataSourceConfig.java

示例8: clusterSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
 * SqlSessionFactory配置
 *
 * @return
 * @throws Exception
 */
@Bean(name = "clusterSqlSessionFactory")
public SqlSessionFactory clusterSqlSessionFactory(
        @Qualifier("clusterDataSource") DataSource dataSource
) throws Exception {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSource);

    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    //配置mapper文件位置
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources(clusterMapperLocations));

    //配置分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    pageHelper.setProperties(properties);

    //设置插件
    sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
    return sqlSessionFactoryBean.getObject();
}
 
开发者ID:Lengchuan,项目名称:SpringBoot-Study,代码行数:31,代码来源:ClusterDruidDataSourceConfig.java

示例9: createSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactory createSqlSessionFactory() throws Exception {
    SqlSessionFactoryBean fb = new SqlSessionFactoryBean();
    fb.setDataSource(roundRobinDataSouceProxy());
    fb.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
    fb.setTypeAliasesPackage(typeAliasesPackage);
    return fb.getObject();
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:9,代码来源:SqlSessionConfiguration.java

示例10: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean  
@ConditionalOnMissingBean  
public SqlSessionFactory sqlSessionFactory() throws Exception {  
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();  
    sqlSessionFactoryBean.setDataSource(roundRobinDataSouceProxy());  
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));
    sqlSessionFactoryBean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);  
    return sqlSessionFactoryBean.getObject();  
}
 
开发者ID:duanyaxin,项目名称:springboot-smart,代码行数:11,代码来源:Application.java

示例11: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean public SqlSessionFactory sqlSessionFactory() throws Exception {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSource());
    //mybatis分页
    PageHelper pageHelper = new PageHelper();
    Properties props = new Properties();
    props.setProperty("dialect", "mysql");
    props.setProperty("reasonable", "true");
    props.setProperty("supportMethodsArguments", "true");
    props.setProperty("returnPageInfo", "check");
    props.setProperty("params", "count=countSql");
    pageHelper.setProperties(props); //添加插件
    sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/me/caixin/dao/mapping/**/*.xml"));
    return sqlSessionFactoryBean.getObject();
}
 
开发者ID:cairenjie1985,项目名称:springBoot-demo,代码行数:18,代码来源:MyBatisAutoConfiguration.java

示例12: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean("sqlSessionFactory")
public SqlSessionFactory sqlSessionFactory() throws Exception {
	SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
	sessionFactory.setDataSource(dataSource());
	sessionFactory.setConfiguration(configuration());
	sessionFactory.setTypeAliasesPackage(entityBasePackage);
	sessionFactory.setTypeAliasesSuperType(AbstractEntity.class);
	sessionFactory.setMapperLocations(getResources(mapperResources));
	OffsetLimitInterceptor offserInterceptor = new OffsetLimitInterceptor();
	offserInterceptor.setDialect(new MySQLDialect());
	MapperInterceptor mapperInterceptor = new MapperInterceptor();
	Properties properties = new Properties();
	properties.setProperty("mappers", mappers);
	properties.setProperty("IDENTITY", dialect);
	mapperInterceptor.setProperties(properties);
	sessionFactory.setPlugins(new Interceptor[] { offserInterceptor ,mapperInterceptor});
	return sessionFactory.getObject();
}
 
开发者ID:swxiao,项目名称:bubble2,代码行数:19,代码来源:MyBatisConfig.java

示例13: businessSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
@Primary
public SqlSessionFactory businessSqlSessionFactory(@Qualifier("businessDataSource") DruidDataSource businessDataSource) throws Exception {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(businessDataSource);
    //mybatis分页
    Properties props = new Properties();
    props.setProperty("dialect", "mysql");
    props.setProperty("reasonable", "true");
    props.setProperty("supportMethodsArguments", "true");
    props.setProperty("returnPageInfo", "check");
    props.setProperty("params", "count=countSql");
    PageHelper pageHelper = new PageHelper();
    pageHelper.setProperties(props);
    //添加插件
    sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPERXML_LOCATION));
    return sqlSessionFactoryBean.getObject();
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:21,代码来源:BusinessDatabaseConfig.java

示例14: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactory sqlSessionFactory( @Autowired DynamicDataSource dynamicDataSource ) {
	try {
		SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
		sessionFactory.setDataSource(dynamicDataSource);
		sessionFactory.setTypeAliasesPackage(this.typeAliasesPackage);
		sessionFactory.setMapperLocations( new PathMatchingResourcePatternResolver().getResources(mapperLocations) );
		sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver().getResource(configLocation));
		
		PageHelper pageHelper = new PageHelper();
		Properties props = new Properties();
		props.setProperty("reasonable", "false");
		props.setProperty("supportMethodsArguments", "true");
		props.setProperty("returnPageInfo", "check");
		props.setProperty("params", "count=countSql");
		pageHelper.setProperties(props);

		sessionFactory.setPlugins(new Interceptor[] { pageHelper });

		return sessionFactory.getObject();
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:chxfantasy,项目名称:micro-service-sample,代码行数:26,代码来源:SessionFactoryConfig.java

示例15: getSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
@Primary
public SqlSessionFactoryBean getSqlSessionFactory() throws IOException {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();

    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Resource[] resources = resolver.getResources("classpath*:/mapper/*.xml");

    bean.setMapperLocations(resources);
    bean.setDataSource(multipleDataSource);
    return bean;
}
 
开发者ID:Wangzr,项目名称:micro-service-framework,代码行数:13,代码来源:WebConfiguration.java


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