Open source software supply chain lighting plan, waiting for you>>>
When you first contact maven, the path of Maven is not the same as that of normal eclipse projects. Java files are placed in Src/main/Java directory, and test files are placed in Src/test/Java directory. The normal test method is to use MVN test for unit test, but you are used to using eclipse. When you test directly in IDE, you will report exception, class not found exception
At the beginning, I thought it was the problem of the build path, because when I was watching maven, someone on the Internet said that they wanted to set the buildpath of eclipse, and then changed it. But sometimes it was good and sometimes it was bad. I felt that the problem was not here. If you think about it more carefully, since it’s class not found, go and look for the class file to see if the directory is correct. Once you look for it, you can find the reason. There is no such class at all. In other words, the java file is not compiled into a class file at all. In eclipse, it can help us compile automatically, but after we run the MVN clean command in maven, we will clean up the compiled class file. At this time, if we use Maven to test and run MVN test, Maven will help you compile again automatically, and the test can run normally. However, if it is directly in eclipse, eclipse will report an exception if it can’t find the compiled class file. The solution is to run the command MVN test to test. After the test is passed, as long as you don’t run MVN clean again, you can also pass the unit test directly in eclipse
The lessons learned this time: don’t rush to check the Internet for some problems. Think about why you report such abnormalities. Think about the deep reasons. Maybe the solution is very simple