问题描述:mvn clean install编译工程并运行单元测试出现如下错误

Tests run: 3, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 6.343 sec <<< FAILURE!
selectUserInfosTest(tech.fullink.eaglehorn.test.UserInfoTest) Time elapsed: 0.003 sec <<< ERROR!
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): tech.fullink.eaglehorn.mapper.UserInfoMapper.getUserInfos

at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:178)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:38)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:42)
at com.sun.proxy.$Proxy18.getUserInfos(Unknown Source)
at tech.fullink.eaglehorn.service.impl.UserInfoServiceImpl.getUserInfos(UserInfoServiceImpl.java:32)
at tech.fullink.eaglehorn.test.UserInfoTest.selectUserInfosTest(UserInfoTest.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

。。。。。

问题的根源出在这个maven项目的 pom文件上

idea在build工程的时候   遇到maven项目   使用的是pom文件里面配置的<build></build>里面的东西

而这里面如果不做特别配置   是maven默认的   编译的时候   只搬运src/main/java里面的java文件到target/classes,其他文件会被忽略

解决办法就是增加配置

<build>

<finalName>eaglehorn-admin</finalName>

<sourceDirectory>src/main/java</sourceDirectory>

<testSourceDirectory>src/test/java</testSourceDirectory>

<outputDirectory>target/classes</outputDirectory>

<testOutputDirectory>target/test-classes</testOutputDirectory>

<resources>

<resource>

<directory>src/main/java</directory>

<includes>

<include>**/*.properties</include>

<include>**/*.xml</include>

<include>**/*.json</include>

</includes>

<filtering>false</filtering>

</resource>

<resource>

<directory>src/main/resources</directory>

<includes>

<include>**/*.properties</include>

<include>**/*.xml</include>

</includes>

<filtering>false</filtering>

</resource>

</resources>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>2.3.2</version>

<configuration>

<source>1.7</source>

<target>1.7</target>

</configuration>

</plugin>

</plugins>

</build>

这样配置之后    idea在builde的时候   或者执行   maven  test  的时候   才能把源码文件夹里的xml文件与java文件一起搬到target/classes   里面去

另外  在eclipse里面   即使pom不做这个特别配置   也没问题    原因是eclipse在build工程的时候   不依赖   maven的pom文件    eclipse的编译器   不会忽略源码文件夹里面的xml文件

Eclipse编译运行没问题,但执行mvn clean install跑单元测试失败的原因解析的更多相关文章

  1. IDEA 中项目代码修改后不自动生效,需要执行 mvn clean install 才生效

    问题描述 之前项目运行好好的,代码修改完之后会自动编译,编程体验很好. 有一天发现每次修改代码后需要重新使用mvn clean install命令重新编译,异常麻烦. 检查了 IDEA 的配置,已经配 ...

  2. 关于导入geoserver 源码到Eclipse编译运行

    参考http://blog.csdn.net/gisshixisheng/article/details/43016443 和  http://blog.sina.com.cn/s/blog_6e37 ...

  3. 使用Eclipse编译运行MapReduce程序 Hadoop2.6.0_Ubuntu/CentOS

    使用Eclipse编译运行MapReduce程序 Hadoop2.6.0_Ubuntu/CentOS  2014-10-10 (updated: 2016-05-22) 64246 153 本教程介绍 ...

  4. 如何在eclipse中使用mvn clean install

    1.在Maven项目或者pom.xml上右键——>Run As ——>“Maven Build...”或者Run Configuration——>“Maven Build” 2.在“ ...

  5. Maven命令行使用:mvn clean install(安装)

    先把命令行切换到Maven项目的根目录,比如:/d/xxxwork/java/maven-test,然后执行命令: $ mvn clean install 执行结果如下: [INFO] Scannin ...

  6. (转)mvn clean install 与 mvn install 的区别(为啥用clean)

    之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,由于之前没有做记录,以及记不清是什么情况下才会出现的问题,于是 ...

  7. mvn clean package 、mvn clean install、mvn clean deploy的区别与联系

    使用的时候首选:mvn clean package mvn clean package依次执行了clean.resources.compile.testResources.testCompile.te ...

  8. pom.xml配置,针对mvn clean install -P参数(环境参数)打包

    pom.xml配置,针对mvn clean install -P参数(环境参数)打包 比如你有2个环境,一个dev,一个prod, 然后你在mvn打包的时候,可以通过-P来打包,是打dev包,还是pr ...

  9. 解决mvn clean install的报错The packaging for this project did not assign a file to the build artifact

    解决mvn clean install的报错The packaging for this project did not assign a file to the build artifact

随机推荐

  1. iframe 自适应

    <iframe src="http://www.fulibac.com" id="myiframe" scrolling="no" o ...

  2. PHP 练习(新闻发布)

    1.新闻发布主页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...

  3. H5 基于Web Storage 的客户端留言板

    <!DOCTYPE html> <html> <head> <meta name="author" content="Yeeku ...

  4. C# Note35: 异步操作

    .NET Framework 为异步操作提供了两种设计模式:使用 IAsyncResult 对象的异步操作与使用事件的异步操作. IAsyncResult 异步设计模式 通过名为 BeginOpera ...

  5. SpringBoot项目优化和Jvm调优(转)

    原文:https://blog.csdn.net/wd2014610/article/details/82182617 项目调优作为一名工程师,项目调优这事,是必须得熟练掌握的事情. 在SpringB ...

  6. 7.docker日志收集

    默认情况下,docker logs或者docker service logs显示命令的输出,就像在终端中以交互方式运行命令时一样.UNIX和Linux命令通常开在运行时间上三个I / O流,所谓的 S ...

  7. dijstra算法

    无向图.赋权有向图 的最短路径

  8. python之动态参数 *args,**kwargs和命名空间

    一.函数的动态参数 *args,**kwargs, 形参的顺序1.你的函数,为了拓展,对于传入的实参数量应该是不固定,所以就需要用到万能参数,动态参数,*args, **kwargs 1,*args ...

  9. ORM关于表那些事

    一.. ORM表和表之间的关系 1. 一对多 --> 外键(ForeignKey) 2. 多对多 --> 另外一张关系表(ManyToManyField) 1. 三种方式 1. 自己建立第 ...

  10. CRLF在过滤XSS语句后打Cookie方式

    看了很长时间的漏洞奖励计划,学到了不少骚姿势,我觉得这个姿势很不错,总结下写篇文章发出来.针对CRLF漏洞打cookie的方法. 这里不讲概念挖掘方式了,以实战为主: 阅读文章前先参考文章:http: ...