在src目录下,新建test.properties配置文件,内容如下 name=root password=123456 logArchiveCron=0/5 * * * * ? 一种是使用spring提供的一个标签,在spring-config.xml中配置单个properties,如下 <context:property-placeholder location="classpath:test.properties"/> 配置多个properties通过分号隔开在后面添…
xml 配置项: <bean id="propertyConfigurer" class="com.boc.icms.archive.util.ExPropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>xdb.properties</value> <value>offline.pro…
1 .系统自带的application.properties  (以下代码仅供参考,不能粘贴复制) 假设application.properties文件有下面两个值: come.test.name = chen come.test.age = 18 come.test.phone = 18795812345 直接在类中的成员变量上添加注解@Value("${ }"),如下 public class Test(){ @Value("${come.test.name}"…
<?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/sch…
http://haohaoxuexi.iteye.com/blog/1900568 //参考文章 实际项目中pom配置如下 <profiles> <profile> <id>dev</id> <properties> <profile.environment>dev</profile.environment> </properties> <activation> <activeByDefaul…
项目中经常用到的配置文件,除了XML文件之外,还会用到Properties文件来存储一些信息,例如国际化的设置.jdbc连接信息的配置等.有时候也会把一些路径或者sql语句放到Properties中,这样就不用直接在Java代码中放置很多sql语句,看起来代码比较整齐.下面就分别用java和js介绍读取properties中的内容. properties文件存储内容,可以简单的认为是key-value格式的,设置一个唯一的关键字,通过该关键字就可以读取它所代表的内容,在Java代码和js代码中读…
applicationContext.xml 是spring的全局配置文件,用来控制srping的特性 1  手动加载自定义的beans.xml文件 @Test public void testAutoWire() throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("ioc/autoWire/beanAutoWire.xml");    //加载包ioc.autoWire下面的b…
一 1.启动一个WEB项目的时候,WEB容器会去读取它的配置文件web.xml,读取<listener>和<context-param>两个结点. 2.紧急着,容创建一个ServletContext(servlet上下文),这个web项目的所有部分都将共享这个上下文. 3.容器将<context-param>转换为键值对,并交给servletContext. 4.容器创建<listener>中的类实例,创建监听器. 二  Load-on-startup Lo…
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp33 加载器目前有两种选择:ContextLoaderListener和ContextLoaderServlet.    这两者在功能上完全等同,只是一个是基于Servlet2.3版本中新引入的Listener接口实现,而另一个基于Servlet接口实现.开发中可根据目标Web容器的实际情况进行选择. 配置非常简单,在web.xml中增加: <listener>     …
最近看了一下Spring源码加载的简装版本,为了更好的理解,所以在绘图的基础上,进行了一些总结.(图画是为了理解和便于记忆Spring架构) Spring的核心是IOC(控制反转)和AOP(面向切面编程),首先我们先一步一步的来了解IOC的实现: 一:首先是第一个模型:Model1:      种子 =  BeanDefinition        工厂=BeanFactory 1.此处我们可以看见两个对象 BeanDefinition和BeanFactory,此处把创建对象的权限交给了Bean…