项目:
http://www.cnblogs.com/hongten/archive/2012/03/09/java_spring_jdbc.html
只需修改:
/spring_1100_spring+jdbc/src/bean.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5 xsi:schemaLocation="http://www.springframework.org/schema/beans
6 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
8 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
9 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
10
11 <context:property-placeholder location="classpath:jdbc.properties" />
12 <bean >48 </beans>
运行效果:
1 2012-3-10 14:30:18 org.springframework.context.support.AbstractApplicationContext prepareRefresh
2 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@15eb0a9: display name [org.springframework.context.support.ClassPathXmlApplicationContext@15eb0a9]; startup date [Sat Mar 10 14:30:18 CST 2012]; root of context hierarchy
3 2012-3-10 14:30:18 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
4 信息: Loading XML bean definitions from class path resource [bean.xml]
5 2012-3-10 14:30:18 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
6 信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@15eb0a9]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1f3aa07
7 2012-3-10 14:30:18 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
8 信息: Loading properties file from class path resource [jdbc.properties]
9 2012-3-10 14:30:18 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
10 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1f3aa07: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,txManager,org.springframework.aop.config.internalAutoProxyCreator,transactionPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice,personService]; root of factory hierarchy
11 ++++++++得到所有Person
12 2 TomCat 12 女
13 3 hongten 21 男
14 4 liufang 21 女
15 5 Divide 20 男
16 6 Jone 20 女
17 7 苏东坡 21 男
18 8 苏东坡 21 男
19 ******************
20 2 TomCat 12 女