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


Java Mapper类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:baomidou,项目名称:mybatisplus-boot-starter,代码行数:27,代码来源:MybatisPlusAutoConfiguration.java

示例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);
    }
}
 
开发者ID:abel533,项目名称:mapper-boot-starter,代码行数:27,代码来源:MapperAutoConfiguration.java

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

示例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);
  }
}
 
开发者ID:mybatis,项目名称:spring-boot-starter,代码行数:25,代码来源:MybatisAutoConfiguration.java

示例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();
    }
}
 
开发者ID:zhyzhyzhy,项目名称:Ink,代码行数:37,代码来源:BeanDefinitionReader.java

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


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