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.