spring5.02クイックスタート

spring5.02クイックスタートは、次の4つのステップに分け、

1.依存紹介

2.プロファイルを作成beans.xmlの

図3は、対応するインタフェースクラスを作成します(唯一の迅速なクラスは、達成するための任意の方法を与えていない、作成)

4.オブジェクトIDを取得するために応じて、コンテナオブジェクトを作成します

次のように詳細な手順は次のとおりです。

1.依存導入
<! -コアに組み込ま依存スプリング- >
<依存性>
<のgroupId> org.springframework </のgroupId>
<たartifactId>ばねコンテキスト</たartifactId>
<バージョン> 5.0.2.RELEASE </バージョン>
</依存関係>
2.プロファイルを作成beans.xmlの

<豆のxmlns = "http://www.springframework.org/schema/beans"
のxmlns:XSI = "http://www.w3.org/2001/XMLSchema-instance"
のxsi:schemaLocationの= "のhttp:// WWW .springframework.org /スキーマ/豆
http://www.springframework.org/schema/beans/spring-beans.xsd ">

</豆>

図3は、対応するインタフェースクラスを作成します(唯一の迅速なクラスは、達成するための任意の方法を与えていない、作成)

4.オブジェクトID取得に基づいて、コンテナオブジェクトを作成する
のApplicationContext ClassPathXmlApplicationContext新しい新しいAC =( "beans.xmlのを");
オブジェクトuserDao = ac.getBean( "userDao");
のSystem.out.println(userDao);
`

おすすめ

転載: www.cnblogs.com/lijun6/p/11117902.html