<?XMLバージョン= "1.0"エンコード= "UTF-8" ?> < 豆のxmlns = "http://www.springframework.org/schema/beans" のxmlns:XSI = "http://www.w3.org/2001 / XMLスキーマ・インスタンス" のxmlns:コンテキスト= "http://www.springframework.org/schema/context" のxmlns:JDBC = "http://www.springframework.org/schema/jdbc" のxmlns:JEEは=" HTTPを: //www.springframework.org/schema/jee」 のxmlns:TX = "http://www.springframework.org/schema/tx" のxmlns:AOP = "http://www.springframework.org/schema/aop" xmlns:MVC = "のhttp://www.springframework。= "http://www.springframework.org/schema/util" のxmlns:JPA = "http://www.springframework.org/schema/data/jpa" のxsi:schemaLocationの=」 のhttp://www.springframework。 ORG /スキーマ/豆http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema /context/spring-context-3.2.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd のhttp:// WWW。 http://www.springframework.org/schema/jee/spring-jee-3.2.xsd springframework.org/schema/jee http://www.springframework.org/schema/tx http://www.springframework.org /schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/data/jpaのhttp://www.springframework .ORG /スキーマ/データ/ JPA /スプリングJPA-1.3.xsd http://www.springframework.org/schema/ http://www.springframework.org/schema/aop/spring-aop-3.2.xsd AOP http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring 3.2.xsd - MVC http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd " > <! - 指定されたクラスDAOスプリングに構成.TestDaoImpl、スプリングせインスタンスを作成- > < ビーン上記ID述べ=「テスト」クラス=「dao.TestDaoImpl」 /> </ 豆>を
試験クラスコード:(インタフェースと実装クラスを排除します)
パッケージテスト; インポートorg.junit.Test; インポートorg.springframework.context.ApplicationContext; インポートorg.springframework.context.support.ClassPathXmlApplicationContext; インポートdao.ITestDao、 パブリック クラスのテスト{ @Test 公共 ボイドTEST1(){ // 初期化春のコンテナのApplicationContextは、コンフィギュレーションファイルをロード = ApplicationContextのAppcon 新しい新 ClassPathXmlApplicationContext( "applicationContext.xmlをする" ); // テスト・インスタンスのコンテナを通じて取得 ITestDao TT =(ITestDao)appCon.getBean( "テスト" ); tt.sayHello(); } }