Eclipse compile run no problem, but do mvn clean install run unit test failure reason resolution

Source: Internet
Author: User

Problem Description: mvn clean install compiles the project and runs the unit test with the following error

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. $Proxy 18.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)

。。。。。

The source of the problem is on the pom file for this MAVEN project

Idea was in the build project when the MAVEN project was using the contents of the <build></build> inside the pom file.

And in this case, if you do not make a special configuration is the MAVEN default compile time only to carry Src/main/java inside the Java files to target/classes, other files will be ignored

The solution is to increase the configuration

<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>


After this configuration, idea will be able to move the XML files in the source folder into the target/classes with the Java files when the Builde or the MAVEN test is executed.



Also in eclipse even if the POM does not do this special configuration is no problem because Eclipse does not rely on the Maven Pom file in the build project Eclipse compiler does not ignore the XML file inside the source folder

Eclipse compile run no problem, but do mvn clean install run unit test failure reason resolution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.