spring03
学习了spring的数据源的使用以及spring的作用域引入外部属性文件
对应的bean的xml文件和properties文件如下
<?xml version="1.0" encoding="UTF-8"?>
<!-- spring 使用外部属性文件 -->
<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/spring-context-4.3.xsd"> <!--
<bean id="datasourse" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="root"></property>
<property name="password" value="000000"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/javawebholiday?useSSL=false"></property>
</bean> -->
<!-- 导入属性文件 --> <context:property-placeholder location="classpath:db2.properties"/>
<bean id="datasourse" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="driverClass" value="${driverClass}"></property>
<property name="jdbcUrl" value="${jdbcUrl}"></property>
</bean> </beans>
user=root
password=
driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/javawebholiday?useSSL=false
<?xml version="1.0" encoding="UTF-8"?>
<!-- 对于bean的作用于的相关的知识点 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- bean 的作用于是通过scope来显示,配置作用于。
默认是singleton,容器初始化时初始化bean的实例,在整个容器的生命周期只创建这一个bean
prototype原型的,容器创建时初始化时不创建bean的实例,二是在每次的请求。都会创建一个新的bean-->
<bean id="car" class="lib3.Car" scope="prototype">
<property name="price" value=""></property>
<property name="brand" value="adiu"></property>
</bean> </beans>
spring03的更多相关文章
- Spring-03 依赖注入(DI)
Spring-03 依赖注入(DI) 依赖注入(DI) 依赖注入(Dependency Injection,DI). 依赖 : 指Bean对象的创建依赖于容器,Bean对象的依赖资源. 注入 : 指B ...
- JAVAEE——spring03:spring整合JDBC和aop事务
一.spring整合JDBC 1.spring提供了很多模板整合Dao技术 2.spring中提供了一个可以操作数据库的对象.对象封装了jdbc技术. JDBCTemplate => JDBC模 ...
- Spring03——有关于 Spring AOP 的总结
本文将为各位带来 Spring 的另一个重点知识点 -- Spring AOP.关注我的公众号「Java面典」,每天 10:24 和你一起了解更多 Java 相关知识点. 什么是 AOP 面向切面编程 ...
- Spring-03
1. AOP相关概念 1.1 AOP概念&作用 AOP(Aspect Oriented Programming)是一种思想,面向切面编程 作用:在不修改源码的前提下,在程序运行过程中对方法进行 ...
- 玩转spring boot——结合jQuery和AngularJs
在上篇的基础上 准备工作: 修改pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=&q ...
- Spring学习总结(一)——Spring实现IoC的多种方式
控制反转IoC(Inversion of Control),是一种设计思想,DI(依赖注入)是实现IoC的一种方法,也有人认为DI只是IoC的另一种说法.没有IoC的程序中我们使用面向对象编程对象的创 ...
- scheme一页纸教程
这是一个大学教授写的,非常好,原文:http://classes.soe.ucsc.edu/cmps112/Spring03/languages/scheme/SchemeTutorialA.html ...
- Spring实现Ioc的多种方式--控制反转、依赖注入、xml配置的方式实现IoC、对象作用域
Spring实现Ioc的多种方式 一.IoC基础 1.1.概念: 1.IoC 控制反转(Inversion of Control) IoC是一种设计思想. 2.DI 依赖注入 依赖注入是实现IoC的一 ...
- MyBatis 实用篇(二)配置文件
MyBatis 实用篇(二)配置文件 一.全局配置 全局配置:http://www.mybatis.org/mybatis-3/zh/configuration.html <?xml versi ...
随机推荐
- Axure 文本框去掉边框 富文本 粘贴文字图标
在今天做原型的过程中,碰到两个问题: 1 文本框该如何去掉边框 2 富文本粘贴文字图标 第一个问题:首先是思路错了,又跑到元件上面找边框,跑到style里面去border的线,结果是不成功. 正解:属 ...
- EPX Studio产品功能介绍
EPX主要面向谁解决什么问题 EPX是什么? EPX基于计算机语言 EPX是利用基于Pascal的FastScript语言作为基础语言,在其中增加了许多函数与特性的一个扩展,将EPX组件本身融入到 ...
- 蓝桥杯vip 字符串对比
蓝桥杯vip 字符串对比 题目如下 给定两个仅由大写字母或小写字母组成的字符串(长度介于1到10之间),它们之间的关系是以下4中情况之一: 1:两个字符串长度不等.比如 Beijing 和 Hebei ...
- 一起了解 .Net Foundation 项目 No.21
.Net 基金会中包含有很多优秀的项目,今天就和笔者一起了解一下其中的一些优秀作品吧. 中文介绍 中文介绍内容翻译自英文介绍,主要采用意译.如与原文存在出入,请以原文为准. UWP Community ...
- Systematic comparison of strategies for the enrichment of lysosomes by data independent acquisition 通过DIA技术系统比较各溶酶体富集策略 (解读人:王欣然)
文献名:Systematic comparison of strategies for the enrichment of lysosomes by data independent acquisit ...
- VsCode编辑器那些事
1.怎么改成中文的? 按快捷键“Ctrl+Shift+P” 在框下点击“configur Display language" 会跳转至商店,选择插件下载“Chinese (Simplifie ...
- hdu1686kmp果题
kmp字符串匹配原理参考博客:https://blog.csdn.net/bqw18744018044/article/details/90516750 代码如下:(写一遍模板) #include&l ...
- 01背包模板题 hdu2602 Bonecollector
由于数组的滚动过程中当前值(i,j)的更新需要用到上一层的(i-1,j-wi)的值,所以在更新当前的j之前不能更新上一层的j之前的值,故01背包是从后向前更新的(重量取值是从大到小的). 代码如下: ...
- JSP(三)----EL表达式
## EL表达式 1.概念:Expression alnguage 表达式语言 2.作用:替换和简化JSP页面中java代码的编写 3.语法:${表达式} 4.注意: * jsp默认支持EL表 ...
- 贪心-Course Schedule III
2020-02-01 21:37:39 问题描述: 问题求解: 对于课程来说截止时间在前面的肯定需要优先安排,所以首先需要将courses按照deadline进行排序. 然后只需要不断的加入当前的课程 ...