In a recent bloggers IDEA+Maven+SpringMVC 4.3.10+Mybatis 3.2.8
do Demo
, so the title before writing the next wave of common exceptions.
Junit4 console unit test error (a)
java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig
Made into the cause of the error is because we web.xml
are using the 3.0
header information, and we cited servlet-api
the jar
version (blogger was using 2.5
version) and Spring4
compatibility issues. Therefore, in pom.xml
in the 2.5
version of the servlet-api
delete, add the following to rely on.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
Error Junit4 console (ii) when the test unit
java.lang.IllegalStateException: Failed to load ApplicationContext
The error occurs because because the use IDEA
is not added during development testing @WebAppConfiguration
notes. It is added to the test class @WebAppConfiguration
notes can be.
Error Junit4 console (iii) when the unit test
Result Maps collection already contains value for
The reason is because the error DAO
class corresponding to the mapper
abnormal files, usually because of <resultMap>
tag id
properties duplicate. This problem frequently occurs when mybatis-genertor
error occurs when a reverse generation. It wants to solve the problem need to mapper
delete the duplicate file contents, but usually run maven
in tomcat
there will be the problem when the plug-in. So if you want to solve this fundamental problem, we need to run out mybatis-genertor
after the plug-in, the pom.xml
file referenced commented plug, then release to use.
Junit4 console errors (four) when unit testing
java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/DefaultIndenter
This is because the error occurs because SpringMVC 4.3.x
the version with jackjson-2.X
the version due to conflict. Therefore, the jackjson
version with a 2.8.7
can.