Yesterday I learned how to use the Spring Test Framework to perform the JUnit integrated unit test. In general, our test class inherits from the abstract class abstractdependencyinjectionspringcontexttests. Note that the method getconfiglocation () should be rewritten (). This test class has the advantage that each test method spring container only initializes beans once. However, in some cases, we do not want to destroy the database in the unit test. In this case, the test class inherits the abstract class abstracttransactionalspringcontexttests. When using this abstract class, pay attention to the injection of the transactionmanager attribute and the datasource attribute of transactionmanager. Otherwise, the test class cannot be initialized and an exception will be thrown: Org. springframework. beans. factory. unsatisfieddependencyexception: Error creating bean with name 'com. ali. luna. CRM. test. biz. train. trainingboimpltest': unsatisfied dependency expressed through bean property 'transactionmanager': set this property value or disable dependency checking for this bean. at org. Springframework. beans. factory. support. abstractautowirecapablebeanfactory. checkdependencies (abstractautowirecapablebeanfactory. java: 1184) at Org. springframework. beans. factory. support. abstractautowirecapablebeanfactory. populatebean (abstractautowirecapablebeanfactory. java: 1006) at Org. springframework. beans. factory. support. abstractautowirecapablebeanfactory. autowirebeanproperties (abstractautowirecapabl Ebeanfactory. java: 329) at Org. springframework. test. abstractdependencyinjectionspringcontexttests. injectdependencies (abstractdependencyinjectionspringcontexttests. java: 205) at Org. springframework. test. abstractdependencyinjectionspringcontexttests. preparetestinstance (abstractdependencyinjectionspringcontexttests. java: 180) at Org. springframework. test. abstractsinglespringcontexttests. setup (abstractsingle Springcontexttests. java: 100) at JUnit. framework. testcase. runbare (testcase. java: 125) at Org. springframework. test. conditionaltestcase. runbare (conditionaltestcase. java: 76) at JUnit. framework. testresult $1. protect (testresult. java: 106) at JUnit. framework. testresult. runprotected (testresult. java: 124) at JUnit. framework. testresult. run (testresult. java: 109) at JUnit. framework. testcase. run (testcase. java: 118) at Juni T. framework. testsuite. runtest (testsuite. java: 208) at JUnit. framework. testsuite. run (testsuite. java: 203) at Org. eclipse. jdt. internal. JUnit. runner. junit3.junit3testreference. run (junit3testreference. java: 130) at Org. eclipse. jdt. internal. JUnit. runner. testexecution. run (testexecution. java: 38) at Org. eclipse. jdt. internal. JUnit. runner. remotetestrunner. runtests (remotetestrunner. java: 467) at Org. eclipse. jdt. inter Nal. JUnit. runner. remotetestrunner. runtests (remotetestrunner. java: 683) at Org. eclipse. jdt. internal. JUnit. runner. remotetestrunner. run (remotetestrunner. java: 390) at Org. eclipse. jdt. internal. JUnit. runner. remotetestrunner. main (remotetestrunner. java: 197) I was troubled by this pitfall for a day. For more information about spring unit testing, visit the following link: http://www.blogjava.net/vcycyv/archive/2011/02/24/345040.html