Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 为什么Mybatis mapper扫描仪选择了错误的类别_Spring_Mybatis - Fatal编程技术网

Spring 为什么Mybatis mapper扫描仪选择了错误的类别

Spring 为什么Mybatis mapper扫描仪选择了错误的类别,spring,mybatis,Spring,Mybatis,我用春天和Mybatis。我将其配置为在整个项目中扫描映射器,并假设它确定了映射器,因为它找到了一个引用java接口的XML文件 但今天这被证明是不正确的,因为我必须添加一个新接口,它不是mapper类,Mybatis认为它是,因此它在我的应用程序中由于以下错误导致问题: 映射语句集合不包含com.blah.MyInterface.someMethod的值 MyInterface只是一个简单的接口,我需要将它包含在Spring上下文中,所以我给了它@Component标记。这个标签用错了吗?这就

我用春天和Mybatis。我将其配置为在整个项目中扫描映射器,并假设它确定了映射器,因为它找到了一个引用java接口的XML文件

但今天这被证明是不正确的,因为我必须添加一个新接口,它不是mapper类,Mybatis认为它是,因此它在我的应用程序中由于以下错误导致问题:

映射语句集合不包含com.blah.MyInterface.someMethod的值

MyInterface只是一个简单的接口,我需要将它包含在Spring上下文中,所以我给了它@Component标记。这个标签用错了吗?这就是困惑的根源吗

我只需要创建这个接口,这样我就可以让代理将我的数据库调用包装在一个地方,在那里我可以放置@Transactional标记,因为Spring在我的控制器方法中忽略它

示例代码

package com.blah.something;

@Component public interface MyInterface {

    public void someMethod( SomeObject obj) throws Exception; 
}


package com.blah.something;

public class MyImplementation implements MyInterface {

        @Transactional
        public void someMethod( SomeObject obj) throws Exception {
              ... do a whole bunch of stuff
        } 
}
我不希望这包括在MyBatis地图中

编辑:根据请求添加mybatis配置xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

    <settings>
        <setting name="lazyLoadingEnabled" value="false" />
        <setting name="defaultStatementTimeout" value="60"/>
    </settings>

    <typeAliases>
      <typeAlias alias="StripTrailingZerosBigDecimalTypeHandler" type="com.blah.typehandlers.StripTrailingZerosBigDecimalTypeHandler"/>
    </typeAliases>

</configuration>

这个接口没有XML,也没有映射器名称空间,它只是一个普通的常规接口,MyBatis不应该认为它是一个映射器服务在它中,我可以根据查找匹配的XML或名称空间来识别映射器接口。我必须在映射器配置中添加一个过滤器,然后引入一个新的注释来注释我的映射器接口。

在mybatis映射xml文件中是否有任何集合映射?能否发布mybatis扫描配置?mybatis配置xml中只有一个关于延迟和查询超时的条目,其中没有映射规范
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.blah" />
</bean>
12/9/13 11:18:44 904 [org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner.findCandidateComponents:4125] - Scanning file [D:\Weblogic\wls11\domains\ldapdomain\autodeploy\default\WEB-INF\classes\com\blah\MyInterface.class]
12/9/13 11:18:44 904 [org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner.findCandidateComponents:4125] - Identified candidate component class: file [D:\Weblogic\wls11\domains\ldapdomain\autodeploy\default\WEB-INF\classes\com\blah\MyInterface.class]
12/9/13 11:18:44 904 [org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner.findCandidateComponents:4125] - Scanning file [D:\Weblogic\wls11\domains\ldapdomain\autodeploy\default\WEB-INF\classes\com\blah\MyImplementation .class]
12/9/13 11:18:44 904 [org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner.findCandidateComponents:4125] - Ignored because not a concrete top-level class: file [D:\Weblogic\wls11\domains\ldapdomain\autodeploy\default\WEB-INF\classes\com\blah\MyImplementation .class]