问题描述: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. WPF动态模板选择的两种实现

    前言 .net开发工作了六年,看了大量的博客,现在想开始自己写博客,这是我的第一篇博客,试试水,就从自己最常使用的WPF开始. 今天我来给大家分享可用户动态选择控件模板的两种实现方式:DataTrig ...

  2. Spring的事件机制详解

    同步事件和异步事件 同步事件:在一个线程里,按顺序执行业务,做完一件事再去做下一件事. 异步事件:在一个线程里,做一个事的同事,可以另起一个新的线程执行另一件事,这样两件事可以同时执行. 用一个例子来 ...

  3. nginx 配置文件的结构

    1.nginx.conf的主要部分 events { } http { server { location path { ... } location path { ... } } server { ...

  4. 【原创】分布式之大话CAP

    引言 本文翻译自博客 http://ksat.me/a-plain-english-introduction-to-cap-theorem/ 博主觉得这个故事讲的生动活泼,因此翻译来给大家分享,顺便加 ...

  5. Linux Crontab Shell脚本实现秒级定时任务

    一.编写Shell脚本crontab.sh #!/bin/bash step=1 #间隔的秒数,不能大于60 for (( i = 0; i < 60; i=(i+step) )); do $( ...

  6. Minieye杯第十五届华中科技大学程序设计邀请赛网络赛D Grid(简单构造)

    链接:https://ac.nowcoder.com/acm/contest/560/D来源:牛客网 题目描述 Give you a rectangular gird which is h cells ...

  7. 软工+C(7): 野生程序员

    // 上一篇:最近发展区/脚手架 // 下一篇:提问和回复 怎样做足够好的软件?我们就差一个程序员! 没有什么软件工程的理论的时候,程序员们凭借自己对编程的热爱,凭借着:"这是一个可以自动化 ...

  8. 通过FactoryBean配置Bean

    这是配置Bean的第三种方式,FactoryBean是Spring为我们提供的,我们先来看看源码: 第一个方法:public abstract T getObject() throws Excepti ...

  9. Python使用turtle库与random库绘制雪花

    记录Python使用turtle库与random库绘制雪花,代码非常容易理解,画着玩玩还是可以的. 完整代码如下:   效果图如下:  

  10. Linux交换分区使用过多的处理办法

    处理办法 echo "vm.swappiness=0" >>/etc/sysctl.conf sysctl -p swapoff -a && swapo ...