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

网站备案为什么 没有批复文件WordPress清爽主题

网站备案为什么 没有批复文件,WordPress清爽主题,襄阳哪里有做网站的,海南房产网站建设Spring框架可以通过Spring的配置文件完成两个数据源druid和C3P0的配置#xff08;Spring#xff1a;IOC/DI配置管理第三方bean#xff09;#xff0c;但是其中包含了一些问题#xff0c;我们来分析下: 这两个数据源中都使用到了一些固定的常量如数据库连接四要素#xf…Spring框架可以通过Spring的配置文件完成两个数据源druid和C3P0的配置SpringIOC/DI配置管理第三方bean但是其中包含了一些问题我们来分析下: 这两个数据源中都使用到了一些固定的常量如数据库连接四要素把这些值写在Spring的配置文件中不利于后期维护需要将这些值提取到一个外部的properties配置文件中 Spring框架如何从配置文件中读取属性值来配置呢 实现思路 需求:将数据库连接四要素提取到properties配置文件spring来加载配置信息并使用这些信息来完成属性注入。 1.在resources下创建一个jdbc.properties(文件的名称可以任意) 2.将数据库连接四要素配置到配置文件中 3.在Spring的配置文件中加载properties文件 4.使用加载到的值实现属性注入 步骤1:准备properties配置文件 resources下创建一个jdbc.properties文件,并添加对应的属性键值对 jdbc.drivercom.mysql.jdbc.Driver jdbc.urljdbc:mysql://127.0.0.1:3306/spring_db jdbc.usernameroot jdbc.passwordroot步骤2:开启context命名空间 在applicationContext.xml中开context命名空间 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd /beans步骤3:加载properties配置文件 在配置文件中使用context命名空间下的标签来加载properties配置文件 context:property-placeholder locationjdbc.properties/步骤4:完成属性注入 使用${key}来读取properties配置文件中的内容并完成属性注入 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd !-- 1.开启context命名空间-- !-- 2.使用context空间加载properties文件--!--方式1 context:property-placeholder locationjdbc.properties system-properties-modeNEVER/-- !--方式2 context:property-placeholder locationjdbc.properties,jdbc2.properties system-properties-modeNEVER/-- !-- classpath:*.properties 设置加载当前工程类路径中的所有properties文件-- !-- system-properties-mode属性是否加载系统属性--!--方式3 context:property-placeholder location*.properties system-properties-modeNEVER/--!--方式4 classpath*:*.properties 设置加载当前工程类路径和当前工程所依赖的所有jar包中的所有properties文件--context:property-placeholder locationclasspath*:*.properties system-properties-modeNEVER/!-- 3.使用属性占位符${}读取properties文件中的属性-- !-- 说明idea自动识别${}加载的属性值需要手工点击才可以查阅原始书写格式--bean iddataSource classcom.alibaba.druid.pool.DruidDataSourceproperty namedriverClassName value${jdbc.driver}/property nameurl value${jdbc.url}/property nameusername value${jdbc.username}/property namepassword value${jdbc.password}//beanbean idbookDao classcom.itheima.dao.impl.BookDaoImplproperty namename value${jdbc.url}//bean/beans说明: 方式一:可以实现如果配置文件多的话每个都需要配置方式二:*.properties代表所有以properties结尾的文件都会被加载可以解决方式一的问题但是不标准方式三:标准的写法classpath:代表的是从根路径下开始查找但是只能查询当前项目的根路径方式四:不仅可以加载当前项目还可以加载当前项目所依赖的所有项目的根路径下的properties配置文件context:property-placeholder/标签会加载系统的环境变量而且环境变量的值会被优先加载,因此增加system-properties-mode:设置为NEVER,表示不加载系统属性 至此读取外部properties配置文件中的内容就已经完成进行测试 public class App {public static void main(String[] args) {ApplicationContext ctx new ClassPathXmlApplicationContext(applicationContext4.xml);DataSource dataSource (DataSource) ctx.getBean(dataSource);System.out.println(dataSource);} }运行结果 加载properties文件小结 本节主要讲解的是properties配置文件的加载需要掌握的内容有: 如何开启context命名空间 如何加载properties配置文件 context:property-placeholder location system-properties-modeNEVER/如何在applicationContext.xml引入properties配置文件中的值 ${key}[说明]内容主要来源黑马程序员网上资源学习
http://www.hkea.cn/news/14374253/

相关文章:

  • wordpress企业站模板罗湖住房和建设局网站
  • 滦平住房和城乡建设厅网站网站建设维护公司资质
  • 西安做网站的公司在线图片制作工具
  • 有网址和关键词就能刷网站排名网络服务设备有哪些
  • 济南网站假设推广网页网站自做全搞定
  • 深圳专业营销网站制作建筑设计公司logo
  • 优秀毕业设计网站设计网络营销具有哪些优势和吸引力
  • 优秀的设计网站有哪些内容珠海网站建设防
  • 成都网站建设桔子科技html5软件安装视频
  • 江西建设职业技术学院招生信息网站wordpress图片无法显示
  • asp.net 网站发布乱码问题wordpress开发+文档下载
  • wordpress给公司建站wordpress 专栏页面
  • 绵阳网站建设策划内容wordpress ftp wp-config.php
  • 电子商务网站建设与运营方向上海网站建设百度推广公司哪家好
  • 厦门人才网个人登录国内好的seo
  • 中山h5网站建设如何利用模板做网站
  • 做银行流水网站ps做特效哪个网站好
  • 广告公司简介模板100字页面优化的方法有哪些
  • 企业解决方案参考网站小说网站用什么虚拟主机
  • 海南网站建设推广同步网站内容怎么做
  • 网站建设的优势是什么意思现在电商做的设计用的什么网站
  • 专业做网站建设制作服务网站建设策划书封面
  • 网站优化比较好的公司个人短信接口wordpress
  • 照明工业网站建设营业执照年检入口
  • 国内flash网站怎么做拍卖网站吗
  • 做一个公司网站的费用溧阳免费做网站
  • 大良营销网站建设咨询wap是什么意思歌词
  • 搭建网站需要多少钱做公司门户网站的重点
  • 网站设计与建设作业可以发布软文的平台
  • 上海电子商务网站建设公司网络营销策划书范文