struts+spring+ibatis的整合使用配置文件方式

12 篇文章 0 订阅
5 篇文章 0 订阅
<?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:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
	
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
	
<!-- 读取jdbc源文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="locations">
 <list>
   <value>classpath:jdbc.properties</value>
 </list>
</property>
</bean>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="poolPreparedStatements" value="true"></property>
</bean>
<!-- 配置ibatis -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="dataSource">
    <ref local="dataSource"/>  
  </property>
  <property name="configLocation">
    <value>classpath:sqlMapConfig.xml</value>
  </property>
</bean>
<!-- 配置声明式事务 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>
<!-- 事务特性 -->
<tx:advice id="txadvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" read-only="false"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.bjpowernode.service.*.*(..))" id="allService"/>
<aop:advisor advice-ref="txadvice" pointcut-ref="allService"/>
</aop:config>
</beans>
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  
  <!-- 读取spring配置文件 -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/applicationContext*.xml</param-value>
  </context-param>
  <!-- 配置监听器 -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <filter>
  
  	<filter-name>struts2</filter-name>
  	<filter-class>
  		org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  	</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>struts2</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping></web-app>
 
# Properties file with JDBC-related settings. 

########## 
# HSQLDB # 
########## 

#jdbc.driverClassName=org.hsqldb.jdbcDriver 
#jdbc.url=jdbc:hsqldb:hsql://localhost:9001/bookstore 
#jdbc.username=sa 
#jdbc.password= 

########### 
# MySQL 5 # 
########### 
  
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/dljd?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=root
jdbc.max=10

#hlj.jdbc.driverClassName=com.mysql.jdbc.Driver
#hlj.jdbc.url=jdbc:mysql://192.168.1.202:3306/bc_ms_hlj?useUnicode=true&characterEncoding=UTF-8
#hlj.jdbc.username=zxc
#hlj.jdbc.password=123

#sd.jdbc.driverClassName=com.mysql.jdbc.Driver
#sd.jdbc.url=jdbc:mysql://192.168.1.202:3306/bc_ms_sd?useUnicode=true&characterEncoding=UTF-8
#sd.jdbc.username=zxc
#sd.jdbc.password=123

#japan.jdbc.driverClassName=com.mysql.jdbc.Driver
#japan.jdbc.url=jdbc:mysql://192.168.1.202:3306/bc_ms_japan?useUnicode=true&characterEncoding=UTF-8
#japan.jdbc.username=zxc
#japan.jdbc.password=123

############## 
# PostgreSQL # 
############## 

#jdbc.driverClassName=org.postgresql.Driver 
#jdbc.url=jdbc:postgresql://localhost/bookstore 
#jdbc.username= 
#jdbc.password= 

############## 
# Oracle 10g # 
############## 

#jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
#jdbc.url=jdbc:oracle:thin:@192.168.1.5:1521:fei
#jdbc.username=jxc
#jdbc.password=jxc

############################# 
# MS SQL Server 2000 (JTDS) # 
############################# 

#jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver 
#jdbc.url=jdbc:jtds:sqlserver://localhost:1433/bookstore 
#jdbc.username= 
#jdbc.password= 


############################# 
# MS SQL Server 2005 (JTDS) # 
############################# 

#jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver
#jdbc.url=jdbc:jtds:sqlserver://localhost:1433/test;instance=SQLEXPRESS
#jdbc.username= 
#jdbc.password= 



################################## 
# MS SQL Server 2000 (Microsoft) # 
################################## 

#jdbc.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
#jdbc.url=jdbc:microsoft:sqlserver://192.168.1.6:1433;DatabaseName=jxcMS
#jdbc.username=JXC
#jdbc.password=JXC

######## 
# ODBC # 
######## 

#jdbc.driverClassName=sun.jdbc.odbc.JdbcOdbcDriver 
#jdbc.url=jdbc:odbc:bookstore 
#jdbc.username= 
#jdbc.password=




#################################################################################

#hibernate.dialect=org.hibernate.dialect.SQLServerDialect
#hibernate.show_sql=false
#hibernate.cache.use_query_cache=false
#hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider



 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
    "http://www.ibatis.com/dtd/sql-map-config-2.dtd">

<sqlMapConfig>          
   <sqlMap resource="com/bjpowernode/bean/user.xml"></sqlMap>     
</sqlMapConfig>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值