当前位置: 首页 > news >正文

网站维护与建设合同星力游戏源码

网站维护与建设合同,星力游戏源码,wordpress首页截断插件,网站做会员系统需求:将数据库连接四要素提取到properties配置文件,spring来加载配置信息并使用这些信息来完成属性注入。第三方bean属性优化的思路如下: 1.在resources下创建一个jdbc.properties(文件的名称可以任意) 2.将数据库连接四要素配置到配置文件中 3.在Spr…

需求:将数据库连接四要素提取到properties配置文件,spring来加载配置信息并使用这些信息来完成属性注入。第三方bean属性优化的思路如下:

1.在resources下创建一个jdbc.properties(文件的名称可以任意)

2.将数据库连接四要素配置到配置文件中

3.在Spring的配置文件中加载properties文件

4.使用加载到的值实现属性注入

其中第3,4步骤是需要重点关注,具体是如何实现。

实现步骤

步骤1:准备properties配置文件

resources下创建一个jdbc.properties文件,并添加对应的属性键值对

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/spring_db
jdbc.username=root
jdbc.password=root

步骤2:开启context命名空间

在applicationContext.xml中开context命名空间

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/springcontext.xsd">
</beans>

步骤3:加载properties配置文件

在配置文件中使用context命名空间下的标签来加载properties配置文件

<context:property-placeholder location="jdbc.properties"/>

步骤4:完成属性注入

使用${key}来读取properties配置文件中的内容并完成属性注入

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/springcontext.xsd">
<context:property-placeholder location="jdbc.properties"/>
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
</beans>

至此,读取外部properties配置文件中的内容就已经完成。

http://www.dinnco.com/news/78882.html

相关文章:

  • web前端怎么做网站响应式设计网站优化推广招聘
  • 国内net开发的网站建设推广之家app下载
  • 网站投票链接怎么做的seo关键字优化教程
  • 网站前台的网址最好的网络营销软件
  • 重点建设学科网站建站 seo课程
  • 电子商务专业网站设计域名权重查询
  • 江阴做公司网站有哪些百度广告代理商查询
  • 柳州网站建设哪家公司好seo优化网站模板
  • 移动互联网开发学什么网站seo软件
  • 网站站内搜索代码营销到底是干嘛的
  • 做二手房比较好的网站有哪些大数据
  • 做网站的工作时间大一html网页制作
  • 推荐系统网站开发百度seo软件首选帝搜软件
  • 苏州高端网站建设企业seo搜索引擎优化求职简历
  • dw做网站模板软文怎么写吸引人
  • 2018做网站开发一个月工资多少深圳网站推广公司
  • 做网站的动态图片企业官方网站怎么申请
  • 徐州做网站的公司招聘广州信息流推广公司排名
  • 网站建设.pdf百度云深圳全网营销方案
  • 怎样增加网站权重网络营销的培训课程
  • 网站添加提醒宣传推广网络推广
  • 时尚网站模板怎么去推广自己的产品
  • 广州建设总承包集团网站推广seo招聘
  • 产品发布网站的装饰怎么做菏泽地网站seo
  • 网站设计的优缺点广州seo网站推广公司
  • 哪个网站教做ppt模板竞价如何屏蔽恶意点击
  • 大庆门户网站国家最新新闻
  • 佛山市城乡住房建设局网站首页搜狗指数官网
  • 织梦网站栏目设计全网营销一站式推广
  • ps做网站要多大seo站外优化最主要的是什么