问答详情
源自:4-1 自定义sql

怎么配置mapper-locations,配置 - com/mp/mapper/*找不到Mapper?

按视频目录建立mapper,在yml配置:

mybatis-plus:
   mapper-locations: 
    - com/mp/mapper/*

这样报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.mp.dao.UserMapper.selectAll,如果把mapper放到resource目录,则下面配置可以:

mybatis-plus:
   mapper-locations: classpath*:mapper/*


提问者:qq_慕瓜5297292 2019-09-12 15:45

个回答

  • 老猿
    2019-09-13 16:15:37
    已采纳

    有时候,按照我视频那样写正常,有时候不正常,不正常的情况下可以在pom.xml文件中加入如下配置:

    	<build>		
    	    <resources>			
    	        <resource>				
    	            <directory>src/main/java</directory>				
    	            <includes>					
    	                <include>**/*.xml</include>				
    	            </includes>
    	        </resource>
    	    </resources>
    	</build>


  • 练习和你说再见
    2020-07-07 15:09:23

    楼主,我遇到了和你一样的问题,你最后怎么解决的呀?


  • qq_慕哥3448606
    2019-09-12 22:25:36

    mybatis-plus:
      mapper-locations: classpath*:mybatis/mapper/*.xml