本文整理匯總了Java中org.apache.ibatis.annotations.Mapper類的典型用法代碼示例。如果您正苦於以下問題:Java Mapper類的具體用法?Java Mapper怎麽用?Java Mapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Mapper類屬於org.apache.ibatis.annotations包,在下文中一共展示了Mapper類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerBeanDefinitions
import org.apache.ibatis.annotations.Mapper; //導入依賴的package包/類
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
logger.debug("Searching for mappers annotated with @Mapper");
ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
try {
if (this.resourceLoader != null) {
scanner.setResourceLoader(this.resourceLoader);
}
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
if (logger.isDebugEnabled()) {
for (String pkg : packages) {
logger.debug("Using auto-configuration base package '" + pkg + "'");
}
}
scanner.setAnnotationClass(Mapper.class);
scanner.registerFilters();
scanner.doScan(StringUtils.toStringArray(packages));
} catch (IllegalStateException ex) {
logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled." + ex);
}
}
示例2: registerBeanDefinitions
import org.apache.ibatis.annotations.Mapper; //導入依賴的package包/類
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
logger.debug("Searching for mappers annotated with @Mapper");
ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
scanner.setMapperProperties(environment);
try {
if (this.resourceLoader != null) {
scanner.setResourceLoader(this.resourceLoader);
}
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
if (logger.isDebugEnabled()) {
for (String pkg : packages) {
logger.debug("Using auto-configuration base package '{}'", pkg);
}
}
scanner.setAnnotationClass(Mapper.class);
scanner.registerFilters();
scanner.doScan(StringUtils.toStringArray(packages));
} catch (IllegalStateException ex) {
logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled.", ex);
}
}
示例3: createClassPathMapperScanner
import org.apache.ibatis.annotations.Mapper; //導入依賴的package包/類
private void createClassPathMapperScanner(BeanDefinitionRegistry registry, String prefixName) {
ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
try {
if (this.resourceLoader != null) {
scanner.setResourceLoader(this.resourceLoader);
}
List<String> packages = AutoConfigurationPackages.get(beanFactory);
packages.forEach(pkg -> log.info("Using auto-configuration base package '{}'", pkg));
scanner.setAnnotationClass(Mapper.class);
scanner.setSqlSessionFactoryBeanName(prefixName + "SessionFactory");
scanner.registerFilters();
scanner.doScan(StringUtils.toStringArray(packages));
} catch (IllegalStateException ex) {
log.info("Could not determine auto-configuration package", ex);
}
}
示例4: registerBeanDefinitions
import org.apache.ibatis.annotations.Mapper; //導入依賴的package包/類
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
logger.debug("Searching for mappers annotated with @Mapper");
ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
try {
if (this.resourceLoader != null) {
scanner.setResourceLoader(this.resourceLoader);
}
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
if (logger.isDebugEnabled()) {
packages.forEach(pkg -> logger.debug("Using auto-configuration base package '{}'", pkg));
}
scanner.setAnnotationClass(Mapper.class);
scanner.registerFilters();
scanner.doScan(StringUtils.toStringArray(packages));
} catch (IllegalStateException ex) {
logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled.", ex);
}
}
示例5: addPackageToScan
import org.apache.ibatis.annotations.Mapper; //導入依賴的package包/類
private void addPackageToScan(String pack) {
try {
Enumeration<URL> resources = Thread.currentThread()
.getContextClassLoader()
.getResources(pack.replace(".", "/"));
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
File file = new File(resource.getPath());
for (File f : file.listFiles()) {
//如果還是個包,則繼續掃描
if (f.isDirectory()) {
addPackageToScan(pack + "." + f.getName());
}
else {
Class<?> class1 = Class.forName(pack + "." + f.getName().replace(".class", ""));
if (containBeanAnnotation(class1)) {
classList.add(class1);
this.register.registerBean(class1.newInstance());
log.info("register bean {}", class1);
}
if (class1.getAnnotation(Mapper.class) != null) {
MybatisConfig.addMapper(class1);
log.info("add mapper {}", class1);
MybatisConfig.buildSessionFactory();
this.register.registerBean(class1.getName(), MybatisConfig.getMapper(class1));
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: makeClass
import org.apache.ibatis.annotations.Mapper; //導入依賴的package包/類
protected TypeSpec.Builder makeClass(TypeElement clazzElement, RedisMapperProperties properties) {
TypeSpec.Builder clazzBuilder = TypeSpec.interfaceBuilder(clazzElement.getSimpleName().toString() + STAFF)
.addModifiers(Modifier.PUBLIC);
clazzBuilder.addAnnotation(Mapper.class);
if (!checkXMLFileExist(clazzElement)) {
AnnotationSpec cacheAnnotation = AnnotationSpec.builder(CacheNamespace.class)
.addMember("flushInterval", "$L", properties.getFlushInterval())
.addMember("implementation", "$L.class", properties.getImplementation())
.addMember("eviction", "$L.class", properties.getEviction())
.addMember("size", "$L", properties.getSize())
.addMember("readWrite", "$L", properties.isReadWrite())
.addMember("blocking", "$L", properties.isBlocking())
.build();
clazzBuilder.addAnnotation(cacheAnnotation);
for (TypeMirror interfaceClass : clazzElement.getInterfaces()) {
clazzBuilder.addSuperinterface(TypeName.get(interfaceClass));
}
clazzBuilder.addSuperinterface(TypeName.get(clazzElement.asType()));
} else {
updateXML(clazzElement, properties);
}
return clazzBuilder;
}