1、リーダーパケット:test.jar
2、@RunWithばね容器を使用してノートを作成 - @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( ":applicationContext.xmlをクラスパス") - @ContextConfigurationを使用して3は、スプリング・コンフィギュレーション・ファイルを読み出します
4、Beanオブジェクトは、組み立て@Resourceを使用して取得しました
パッケージcom.sikiedu.test; 輸入javax.annotation.Resource; 輸入org.junit.Test; 輸入org.junit.runner.RunWith; 輸入org.springframework.test.context.ContextConfiguration。 輸入org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 輸入com.sikiedu.service.UserService。 @RunWith(SpringJUnit4ClassRunner。クラス) @ContextConfiguration( "クラスパス:applicationContext.xmlを" ) パブリック クラスAopTest { // 将名为UserServiceの的对象注入到UserServiceの中 @Resource(名前= "UserServiceの" ) プライベートUserServiceの私たち; @Test 公共 ボイドTEST2(){ us.delete()。 } }