- 手動でのjarパッケージをダウンロードする方法
Mavenのjarファイルパッケージに春をダウンロードし、アドレスは次のとおりです。http://maven.springframework.org/release/org/springframework/spring/
あなたは春のjarパッケージのさまざまなバージョンをダウンロードすることができます。
例において4.3.9、圧縮ダウンロードDIST
解凍後のコアのjarパッケージが存在し、使用する必要があります
スプリングaop.jar(JARはAOPの開発が必要)、...豆(処理された豆のJAR)、...コンテキスト(ジャースプリングプロセスコンテキスト)、...コア(スプリングコアジャー)、.. .expersion(スプリング式)
また、サードlogging.jarコモンズが必要 https://mvnrepository.com/artifact/commons-logging/commons-logging/1.1.1
自動要求するメッセージが表示されたら、あなたはプラグインSTS春インストールする必要があります
ダウンロードhttps://spring.io/tools/sts/allアドレスに対応するバージョンを
または直接公式STSツールhttps://spring.io/tools/stsを使用して
- 設定ファイルを書きます
STSをインストールした後、applicationContext.xmlを呼ばれるプロジェクトで指定された豆の構成を作成
XMLファイルには、Beanを構成することができます
試験例で豆Studentクラス(3つの属性stuName、stuAge、stuNo)
XML:
<?XMLバージョン= "1.0"エンコード= "UTF-8" ?> < 豆のxmlns = "http://www.springframework.org/schema/beans" のxmlns:XSI = "http://www.w3.org/2001 / XMLスキーマ・インスタンス" のxsi:のschemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" > < ビーンID ="生徒" クラス=" com.beans.Student」> < プロパティ名= "stuNo" 値= "2" > </ プロパティ> <> </ プロパティ> < プロパティ名= "stuAge" 値= "20" > </ プロパティ> </ ビーン> </ 豆>
テストカテゴリ:
パッケージcom.test。 輸入org.springframework.context.ApplicationContext; 輸入org.springframework.context.support.ClassPathXmlApplicationContext; 輸入com.beans.Student。 パブリック クラスのテスト{ 公共 静的 ボイドメイン(文字列[]引数){ ApplicationContextのコンテキスト = 新しい ClassPathXmlApplicationContext(「applicationContext.xmlを」)。 学生学生 =(学生)context.getBean( "学生" )。 System.out.println(学生)。 } }