本文整理汇总了Java中org.mybatis.spring.mapper.MapperFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java MapperFactoryBean类的具体用法?Java MapperFactoryBean怎么用?Java MapperFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapperFactoryBean类属于org.mybatis.spring.mapper包,在下文中一共展示了MapperFactoryBean类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newMyBatisMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Object newMyBatisMapper(MapperBasicConfig config) {
MapperFactoryBean mapperFactoryBean = new MapperFactoryBean();
mapperFactoryBean.setMapperInterface(config.getMapperInterface());
mapperFactoryBean.setSqlSessionFactory(this.getSqlSessionFactory(config.getDataSourceName(),
config.getMapperInterface()));
mapperFactoryBean.afterPropertiesSet();
Object mapper = null;
try {
mapper = mapperFactoryBean.getObject();
} catch (Exception e) {
throw new MapperInitializeException(e);
}
return mapper;
}
示例2: userDaoWithFactory
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
@Bean
public UserDao userDaoWithFactory() throws Exception {
MapperFactoryBean<UserDao> mapperFactoryBean = new MapperFactoryBean<UserDao>();
mapperFactoryBean.setMapperInterface(UserDao.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
mapperFactoryBean.afterPropertiesSet();
return mapperFactoryBean.getObject();
}
示例3: postProcessBeanDefinitionRegistry
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
if (!enabled) {
return;
}
for (String beanName : registry.getBeanDefinitionNames()) {
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
if (MapperFactoryBean.class.getName().equals(beanDefinition.getBeanClassName())) {
beanDefinition.setBeanClassName(LazyFactoryBean.class.getName());
}
}
}
示例4: deviceMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/** The Device mapper to be used by the managers
*
* @return THe device mapper
* @throws Exception If fetching the sql session factory failed
*/
@Bean
public DeviceMapper deviceMapper() throws Exception {
MapperFactoryBean<DeviceMapper> mapperFactoryBean = new MapperFactoryBean<DeviceMapper>();
mapperFactoryBean.setMapperInterface(DeviceMapper.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
return mapperFactoryBean.getObject();
}
示例5: deviceImageMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/** The Device Image mapper to be used by the managers
*
* @return The device image mapper
* @throws Exception If fetching the sql session factory failed
*/
@Bean
public DeviceImageMapper deviceImageMapper() throws Exception {
MapperFactoryBean<DeviceImageMapper> mapperFactoryBean = new MapperFactoryBean<DeviceImageMapper>();
mapperFactoryBean.setMapperInterface(DeviceImageMapper.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
return mapperFactoryBean.getObject();
}
示例6: fileMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/** The File mapper to be used by the managers
*
* @return The file mapper
* @throws Exception If fetching the sql session factory failed
*/
@Bean
public FileMapper fileMapper() throws Exception {
MapperFactoryBean<FileMapper> mapperFactoryBean = new MapperFactoryBean<FileMapper>();
mapperFactoryBean.setMapperInterface(FileMapper.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
return mapperFactoryBean.getObject();
}
示例7: userMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/** The User mapper to be used by the managers
*
* @return The user mapper
* @throws Exception If fetching the sql session factory failed
*/
@Bean
public UserMapper userMapper() throws Exception {
MapperFactoryBean<UserMapper> mapperFactoryBean = new MapperFactoryBean<UserMapper>();
mapperFactoryBean.setMapperInterface(UserMapper.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
return mapperFactoryBean.getObject();
}
示例8: registrationKeyMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/** The RegistrationKey Mapper
*
* @return The user mapper
* @throws Exception If fetching the sql session factory failed
*/
@Bean
public RegistrationKeyMapper registrationKeyMapper() throws Exception {
MapperFactoryBean<RegistrationKeyMapper> mapperFactoryBean = new MapperFactoryBean<RegistrationKeyMapper>();
mapperFactoryBean.setMapperInterface(RegistrationKeyMapper.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
return mapperFactoryBean.getObject();
}
示例9: userAuthenticationTokenMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/** The UserAuthenticationToken mapper
*
* @return The user mapper
* @throws Exception If fetching the sql session factory failed
*/
@Bean
public UserAuthenticationTokenMapper userAuthenticationTokenMapper() throws Exception {
MapperFactoryBean<UserAuthenticationTokenMapper> mapperFactoryBean = new MapperFactoryBean<UserAuthenticationTokenMapper>();
mapperFactoryBean.setMapperInterface(UserAuthenticationTokenMapper.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
return mapperFactoryBean.getObject();
}
示例10: requestMapper
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/** The Request Mapper to be used by the controllers
*
* @return The request mapper
* @throws Exception If fetching the sql session factory failed
*/
@Bean
public RequestMapper requestMapper() throws Exception {
MapperFactoryBean<RequestMapper> mapperFactoryBean = new MapperFactoryBean<RequestMapper>();
mapperFactoryBean.setMapperInterface(RequestMapper.class);
mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory());
return mapperFactoryBean.getObject();
}
示例11: afterPropertiesSet
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
@PostConstruct
public void afterPropertiesSet() {
logger.debug("No " + MapperFactoryBean.class.getName() + " found.");
}
示例12: afterPropertiesSet
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
@PostConstruct
public void afterPropertiesSet() {
logger.debug("No {} found.", MapperFactoryBean.class.getName());
}
示例13: afterPropertiesSet
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
@PostConstruct
public void afterPropertiesSet() {
logger.debug("No {} found.", MapperFactoryBean.class.getName());
}
示例14: doScan
import org.mybatis.spring.mapper.MapperFactoryBean; //导入依赖的package包/类
/**
* Calls the parent search that will search and register all the candidates. Then the
* registered objects are post processed to set them as MapperFactoryBeans
*/
@Override
protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);
if (beanDefinitions.isEmpty()) {
logger.warn("No MyBatis mapper was found in '" + MapperScannerConfigurer.this.basePackage
+ "' package. Please check your configuration.");
} else {
for (BeanDefinitionHolder holder : beanDefinitions) {
GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();
if (logger.isDebugEnabled()) {
logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName()
+ "' and '" + definition.getBeanClassName() + "' mapperInterface");
}
// the mapper interface is the original class of the bean
// but, the actual class of the bean is MapperFactoryBean
definition.getPropertyValues().add("mapperInterface", definition.getBeanClassName());
definition.setBeanClass(MapperFactoryBean.class);
definition.getPropertyValues().add("addToConfig", MapperScannerConfigurer.this.addToConfig);
boolean explicitFactoryUsed = false;
if (StringUtils.hasLength(MapperScannerConfigurer.this.sqlSessionFactoryBeanName)) {
definition.getPropertyValues().add("sqlSessionFactory", new RuntimeBeanReference(MapperScannerConfigurer.this.sqlSessionFactoryBeanName));
explicitFactoryUsed = true;
} else if (MapperScannerConfigurer.this.sqlSessionFactory != null) {
definition.getPropertyValues().add("sqlSessionFactory", MapperScannerConfigurer.this.sqlSessionFactory);
explicitFactoryUsed = true;
}
if (StringUtils.hasLength(MapperScannerConfigurer.this.sqlSessionTemplateBeanName)) {
if (explicitFactoryUsed) {
logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
}
definition.getPropertyValues().add("sqlSessionTemplate", new RuntimeBeanReference(MapperScannerConfigurer.this.sqlSessionTemplateBeanName));
definition.getPropertyValues().add("sqlSessionFactory", null);
} else if (MapperScannerConfigurer.this.sqlSessionTemplate != null) {
if (explicitFactoryUsed) {
logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
}
definition.getPropertyValues().add("sqlSessionTemplate", MapperScannerConfigurer.this.sqlSessionTemplate);
definition.getPropertyValues().add("sqlSessionFactory", null);
}
}
}
return beanDefinitions;
}