maven build resources
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的更多相关文章
- maven pom 中的 build——resources 标签 mybatis加载mapper类及.xml文件
转: maven 理解 2017年12月18日 15:34:31 feicongcong 阅读数:5658 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn ...
- Java 在pom.xml中配置build resources, 来防止我们资源导出失败问题(Maven项目)
在pom.xml中配置build, 来防止我们资源导出失败问题 <!--在build中配置resources, 来防止我们资源导出失败问题--> <build> <res ...
- 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 ...
- Maven Build profiles
They modify the POM at build time, and are meant to be used in complementary sets to give equivalent ...
- Maven Build Profiles--reference
What is Build Profile? A Build profile is a set of configuration values which can be used to set or ...
- 利用maven的resources、filter和profile实现不同环境使用不同配置文件
基本概念说明(resources.filter和profile): 1.profiles定义了各个环境的变量id 2.filters中定义了变量配置文件的地址,其中地址中的环境变量就是上面profil ...
- Maven Build Life Cycle--reference
What is Build Lifecycle? A Build Lifecycle is a well defined sequence of phases which define the ord ...
- 利用maven中resources插件的copy-resources目标进行资源copy和过滤
maven用可以利用如下配置进行资源过滤,pom.xml的配置如下: <build> <!-- 主资源目录 --> <resources> <resource ...
- maven build pulgin
<build> <defaultGoal>compile</defaultGoal> <plugins> <!-- 生成清单文件相关 --> ...
随机推荐
- animate.css做点赞效果
花了一晚上研究出来的,感觉还行吧... 代码: 源码下载: http://image.niunan.net/animatedemo.zip
- atitit 各分公司ceo cao行政经理职责.docx
1.1. 人员招募--分公司高层人员招募(每月招募四五人吧,每周一人平均) 1 1.2. 组织架构优化 1 1.3. 制度建设 健全并完善分公司内部管理机构设置,优化分公司业务管理流程: 1 1.4 ...
- vim常用技巧
# vim常用技巧 ## 行操作------------------------------ 行首 0- 行尾 $- 第一个非空字符 ^ ## 列编辑模式----------------------- ...
- 匿名函数gc分析
测试一:使用member function创建action会产生gc,不管该函数是否访问外部变量: private System.Action memberAct = null; // gc 112B ...
- 【ML入门系列】(三)监督学习和无监督学习
概述 在机器学习领域,主要有三类不同的学习方法: 监督学习(Supervised learning) 非监督学习(Unsupervised learning) 半监督学习(Semi-supervise ...
- Android 8 蓝牙打开过程
packages\apps\Settings\src\com\android\settings\bluetooth\BluetoothEnabler.java @Override public boo ...
- 使用.gitignore删除Github上的.idea文件
环境:windows + git bash. 一.问题来源 由于之前用Goland建立Golang工程时,生成了.idea文件,不小心上传至Github: 所以尝试用.gitignore进行忽略不上传 ...
- GoLang之错误处理
错误处理 error Go语言引入了一个错误处理的标准模式,即error接口,该接口定义如下: type error interface { Error() string } 对于大多数函数,如果要返 ...
- ajax方法如何给全局变量赋值
在调用一个jquery的ajax方法时我们有时会需要该方法返回一个值或者给某个全局变量赋值,可是我们发现程序执行完后并没有获取到我们想要的值,这时很有可能是因为你用的是ajax的异步调用async:t ...
- PHP实现URL长连接转短连接方法总结
短链接,通俗来说,就是将长的URL 网址,通过程序计算等方式,转换为简短的网址字符串. 这样的话其好处为:1.内容需要:2.用户友好:3.便于管理. 实现短网址(short URL)系统比较流行的算法 ...