Precautions for maven + spring + junit testing: mavenjunit

Source: Internet
Author: User

Precautions for maven + spring + junit testing: mavenjunit

There are a lot of online documents for creating a webapp project using maven, which is not detailed here. After the creation, I mentioned that I had to switch to version 3.0 when switching to a dynamic web project, but I couldn't switch it locally. The method on the Internet seems useless, and I haven't used it for the moment. After the SSM framework is set up, let's talk about this. Today, I want to talk about the problem of spring-targeted junit unit testing when I set up the SSM framework based on a tutorial on the Internet. Because of the maven version management, I have never jumped out. Solved the problem yesterday afternoon. This problem may not occur in other eclipse or other environments, but I 'd like to remind you. Follow the tutorial below for release (4.11) and spring-test (4.1.7) versions. The following error initializationError is displayed during the unit test.

If you want to use the jar package of spring-test for unit testing, junit must be of junit4 or later. You only need to replace spring-related versions with other versions of spring4. Here I will replace it4.0.2Version to pass the unit test.

Ps: When I use the ssm framework for unit testing, I feel that "configuration first", various bean objects, SQL configurations, and so on are all loaded synchronously when the configuration file is loaded, if you are not familiar with the entire process and have a problem, it is a deep trap.

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.