1、在我用springboot+mytatis时,生成完mapper后,然后访问网站总是报错

错误信息:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.insurance.repository.MOperateLogMapper.selectByExample] with root cause
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.insurance.repository.MOperateLogMapper.selectByExample
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
at com.sun.proxy.$Proxy64.selectByExample(Unknown Source)
at com.insurance.services.impl.OperateLogService.getDataGridDataByCondition(OperateLogService.java:37)
at com.insurance.backend.controller.LogOperateController.getDataGridDataByCondition(LogOperateController.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

经过排查,发现是classpath(即表示target下的classses文件夹)下,没有生成mapper.xml

2、解决,在repository项目的pom文件中,加上build resources即可,如图

生成结果

最后要想能运行,还要配置MapperScan的扫描基础包

3、延伸

(1)、filtering

我自己实践中的一个例子:

当此filtering为true时,结果竟是

这表明,当设置了filtering为true时,<directory>src/main/resources</directory>文件夹下的文件,如某些js呀等等,可能被application.yml中配置的某些变量替代了

所以,没有特别需求, 应该不对build-resources下的<directory>src/main/resources</directory>进行设置;或者如果进行设置,让filtering为false最好

(2)、pom文件中的,build-resources,如果不进行特殊设置,默认会按如下图描述方式;

对<directory>src/main/resources</directory>来说,如果进行了设置,就会按照设置的进行,例:

对<directory>src/main/java</directory>来说,即使进行了设置(当然是不进行排除.class文件设置),也会把默认的编译后.class文件放到classpath中

maven build resources的更多相关文章

  1. maven pom 中的 build——resources 标签 mybatis加载mapper类及.xml文件

    转: maven 理解 2017年12月18日 15:34:31 feicongcong 阅读数:5658   版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn ...

  2. Java 在pom.xml中配置build resources, 来防止我们资源导出失败问题(Maven项目)

    在pom.xml中配置build, 来防止我们资源导出失败问题 <!--在build中配置resources, 来防止我们资源导出失败问题--> <build> <res ...

  3. maven:log4j:WARN No appenders could be found for logger (loggerInfo).或者maven build error:org.apache.maven.lifecycle.LifecycleExecutionExceptio

    maven在build构建时,加载资源文件时需要配置资源文件插件: 1,在pom.xml文件中加入 <build> <finalName>${project.build.tar ...

  4. Maven Build profiles

    They modify the POM at build time, and are meant to be used in complementary sets to give equivalent ...

  5. Maven Build Profiles--reference

    What is Build Profile? A Build profile is a set of configuration values which can be used to set or ...

  6. 利用maven的resources、filter和profile实现不同环境使用不同配置文件

    基本概念说明(resources.filter和profile): 1.profiles定义了各个环境的变量id 2.filters中定义了变量配置文件的地址,其中地址中的环境变量就是上面profil ...

  7. Maven Build Life Cycle--reference

    What is Build Lifecycle? A Build Lifecycle is a well defined sequence of phases which define the ord ...

  8. 利用maven中resources插件的copy-resources目标进行资源copy和过滤

    maven用可以利用如下配置进行资源过滤,pom.xml的配置如下: <build> <!-- 主资源目录 --> <resources> <resource ...

  9. maven build pulgin

    <build> <defaultGoal>compile</defaultGoal> <plugins> <!-- 生成清单文件相关 --> ...

随机推荐

  1. Google protobuf解析消息逻辑的版本问题

    在分析caffe2源码的过程中,由于caffe2使用protobuf作为网络结构和网络参数序列化和反序列化的机制,想在反序列化之前进行加解密处理,这是反向protouf其实有两个版本的实现来进行消息的 ...

  2. python(61):str 和 bytes 转换

    str 和 bytes 转换 b = b"example" # str object s = "example" # str to bytes bytes(s, ...

  3. Python中的retry

    1.通过语言特性实现: for i in range(0,100): while True: try: # do stuff except SomeSpecificException: continu ...

  4. SpringBoot 全配置(推荐收藏)

    # =================================================================== # COMMON SPRING BOOT PROPERTIE ...

  5. 基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】搭建HAWQ数据仓库——安装配置OPEN-SSH,设置主机节点之间免密互访

    配置root用户免密互访(为了方便,各台系统中使用统一的证书文件)一.安装Open-SSH 1,查询系统中是否安装了openssh [root@]# opm -qa |grep ssh 如已安装,则列 ...

  6. Java编程常见缺陷汇总(一)

     [案例1] public boolean equalNode(JudgeNode a, JudgeNode b) { return a.getId() == b.getId(); } [点评] 应在 ...

  7. css布局 - 两栏自适应布局的几种实现方法汇总

    这种两列布局的样式是我们在平时工作中非常常见的设计,同时也是面试中要求实现的高频题.很有必要掌握以备不时之需: 整理了几种实现方法,当然,风骚的代码不止这几种能实现,欢迎各位的补充. 方法汇总目录 简 ...

  8. HashTab---Windows资源管理器的文件属性窗口中添加了一个叫做”文件校验”的标签

    HashTab 是一个优秀的 Windows 外壳扩展程序,它在 Windows 资源管理器的文件属性窗口中添加了一个叫做”文件校验”的标签.该标签可以帮助你方便地计算文件的 MD5.SHA1 与 C ...

  9. express.js graphql express-graphql

    文档 创建应用 const l = console.log; var express = require("express"); var graphqlHTTP = require ...

  10. 使用call、apply和bind解决js中烦人的this,事件绑定时的this和传参问题

    1.什么是this 在JavaScript中this可以是全局对象.当前对象或者任意对象,这完全取决于函数的调用方式,this 绑定的对象即函数执行的上下文环境(context). 为了帮助理解,让我 ...