=================== 配置文件参数化_开发 =================== 1 增加小配置文件 名字随意,位置随意,必须以.properties作为后缀。 /src/main/resources/jdbc.properties: jdbc.driver = com.mysql.jdbc.Driver jdbc.url = jdbc:mysql://localhost:3306/springdb?useSSL=false jdbc.username = root jdbc.password = 123456 2 整合Spring配置文件和小配置文件 /src/main/resources/applicationContext.xml: resources目录下的文件在编译后都位于classes目录下,classpath即指向该目录。 3 在Spring配置文件中通过键引用小配置文件中的值 /src/main/resources/applicationContext.xml: Found key 'jdbc.driver' in PropertySource 'localProperties' with value of type String Found key 'jdbc.url' in PropertySource 'localProperties' with value of type String Found key 'jdbc.username' in PropertySource 'localProperties' with value of type String Found key 'jdbc.password' in PropertySource 'localProperties' with value of type String 例程:Injection