當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。