spring中jdbc.properties用法
2014-05-29 19:02
369 查看
jdbc.properties代码:
applicationContext.xml代码:
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver jdbc.url=jdbc:oracle:thin:@10.10.1.1:1521:ORCL jdbc.username=test jdbc.password=test
applicationContext.xml代码:
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd "> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/WEB-INF/jdbc.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"> </property> <property name="url" value="${jdbc.url}"> </property> <property name="username" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.OracleDialect </prop> </props> </property> <property name="mappingResources"> <list> <value>com/xy6/form/LoginForm.hbm.xml</value> </list> </property> </bean> <!-- 指定事务管理器类,将sessionFactory注入,让该事务管理器具有打开和关闭事务的能力 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 为事务管理器类指定匹配器,通过用name指定的匹配字符串进行对对应的方法进行打开和关闭事务 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="modify*" propagation="REQUIRED" /> <tx:method name="deploy*" propagation="REQUIRED" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <!-- 为事务管理器类指定进行匹配的范围,到指定的地方通过匹配器字符串进行筛选,对应上后为该方法打开和关闭事务 --> <aop:config proxy-target-class="true"> <aop:pointcut id="managerOperation" expression="execution(* com.xy6.dao.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="managerOperation" /> </aop:config> <!-- 该 BeanPostProcessor 将自动对标注 @Autowired 的 Bean 进行注入 --> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/> <!-- 使用annotation 自动注册bean,并检查@Required,@Autowired的属性已被注入 --> <context:component-scan base-package="com.xy6"/> <!-- spring转发 --> <bean name="/login" class="com.xy6.action.LoginAction"> </bean> <bean id="loginAction" class="com.xy6.action.LoginAction"></bean> <bean id="loginService" class="com.xy6.service.impl.LoginServiceImpl"></bean> <bean id="loginDAO" class="com.xy6.dao.impl.LoginDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> </beans>
相关文章推荐
- spring中jdbc.properties用法 - 连接mysql
- spring中jdbc.properties配置文件用法
- Spring 使用配置文件读取jdbc.properties
- Spring使用配置文件读取jdbc.properties
- spring jdbc.properties
- spring jdbc.properties
- spring jdbc.properties
- spring.xml 配置加载jdbc.properties和ehcache.xml 的方法
- spring jdbc.properties
- spring jdbc.properties
- spring jdbc.properties
- spring jdbc.properties
- spring和mybatis整合加载jdbc.properties异常
- Spring+mybatis+maven整合过程加载配置文件jdbc.properties
- Spring JDBC 核心用法大总
- spring jdbc.properties
- Spring使用配置文件读取jdbc.properties
- SpringJdbc的几种不同的用法
- Spring_SpringMVC_MyBaties框架搭建是 jdbc.properties文件注意事项
- spring jdbc.properties