Maven + SSM project development under the framework of common exceptions and solutions (IV)

In a recent bloggers IDEA+Maven+SpringMVC 4.3.10+Mybatis 3.2.8do 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.xmlare using the 3.0header information, and we cited servlet-apithe jarversion (blogger was using 2.5version) and Spring4compatibility issues. Therefore, in pom.xmlin the 2.5version of the servlet-apidelete, 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 IDEAis not added during development testing @WebAppConfigurationnotes. It is added to the test class @WebAppConfigurationnotes can be.

Error Junit4 console (iii) when the unit test

Result Maps collection already contains value for

The reason is because the error DAOclass corresponding to the mapperabnormal files, usually because of <resultMap>tag idproperties duplicate. This problem frequently occurs when mybatis-genertorerror occurs when a reverse generation. It wants to solve the problem need to mapperdelete the duplicate file contents, but usually run mavenin tomcatthere will be the problem when the plug-in. So if you want to solve this fundamental problem, we need to run out mybatis-genertorafter the plug-in, the pom.xmlfile 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.xthe version with jackjson-2.Xthe version due to conflict. Therefore, the jackjsonversion with a 2.8.7can.

Guess you like

Origin blog.csdn.net/Supreme_Sir/article/details/94746187