Springプロファイルプレースホルダを使用した構成
Spring PropertyPlaceholderConfigurerプレースホルダの使用
1、Springのフレームの中で、org.springframework.beans.factory.config.P r o p e r t y PlaceholderConfigurerクラスは.properties(key/value形式)ファイルのいくつかの動的に設定された値(value)は、xmlでキー($key$)の値に置換.propertiesファイルは、お客様のニーズに応じて、関連するパラメータをカスタマイズできます.このような設計は、プログラムの柔軟性を提供します.
2.SpringでP r o p e r t y PlaceholderConfigurerを使用してxmlプロファイルに外部属性ファイルを追加する
2.1.外部ファイルのエンコーディング(location)を指定できます.
1、Springのフレームの中で、org.springframework.beans.factory.config.P r o p e r t y PlaceholderConfigurerクラスは.properties(key/value形式)ファイルのいくつかの動的に設定された値(value)は、xmlでキー($key$)の値に置換.propertiesファイルは、お客様のニーズに応じて、関連するパラメータをカスタマイズできます.このような設計は、プログラムの柔軟性を提供します.
2.SpringでP r o p e r t y PlaceholderConfigurerを使用してxmlプロファイルに外部属性ファイルを追加する
2.1.外部ファイルのエンコーディング(location)を指定できます.
classpath:/spring/include/dbQuery.properties
UTF-8
2.2、 (locations), :
/WEB-INF/mail.properties
classpath: conf/sqlmap/jdbc.properties // value
ここでclasspathはsrcディレクトリを したファイルの き です.
2.3. に、 のP r e r t y P e r e c e holderConfigurerを して を し、 のエンジニアリングの で の したP r e tiesファイルを し、その は の りである.
classpath:/spring/include/dbQuery.properties
classpath:/spring/include/jdbc-parms.properties
classpath:/spring/include/base-config.properties
ここでorderプロパティはそのロード を し、ignoreUnresolvablePlaceholdersは なPlaceholderを するかどうかであり、 のPropertyPlaceholderConfigurerが されている はtrueに する があります.
3、jdbc.propertiesの は のとおりです.jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/mysqldb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=round;
jdbc.username=root
jdbc.password=123456
4、springプロファイルでは、 のように くことができます.
5、P r o p e r t y PlaceholderConfigurerが たす は、プレースホルダが すデータベース をbeanで するツールです.