Spring中properties的应用

Spring中properties的应用

举例:
1.在Maven的pom.xml里面设置引入的各个jar包的版本,曾使用过如下写法。
在这里插入图片描述

在各子项目引入jar包的pom.xml里面使用过:
在这里插入图片描述

在各子项目spring-config.xml里面引入属性配置文件
在这里插入图片描述
而jdbc.properties里的内容为:
db.driver=com.mysql.cj.jdbc.Driverdb.reader.url=jdbc:mysql://192.168.0.251:3306/bonade_center?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=PRC&useSSL=falsedb.reader.username=rootdb.reader.password=sOGhhAUYuM7=db.writer.url=jdbc:mysql://192.168.0.251:3306/bonade_center?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=PRC&useSSL=falsedb.writer.username=rootdb.writer.password=sOGhhAUYuM7=db.initialSize=20db.maxActive=40db.maxIdle=20db.minIdle=1db.maxWait=60000db.timeBetweenEvictionRunsMillis=3000db.minEvictableIdleTimeMillis=300000db.maxPoolPreparedStatementPerConnectionSize=20druid.filters=

而dataSource.xml里面配置的内容是:
只写数据库连接

在mybatis.xml里的配置为:
spring和MyBatis完美整合,不需要mybatis的配置映射文件DAO接口所在包名,Spring会自动查找其下的类<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

此处的datasource链接的就是datasource.xml里的配置,而datasource.xml里的
在这里插入图片描述链接的就是
在这里插入图片描述而db.driver就是jdbc.properties文件里的配置了。
在这里插入图片描述

PS:
在这里插入图片描述在这里插入图片描述在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_40821669/article/details/88420372