Struts2.0和webwork2以上版本有很多类似的特性,前面已写了一篇有关webwork+spring+ibatis的拙作,为了省去罗嗦,在本篇文章中仅就对前篇文章未涉及到特性做些说明,并写了一则小例子,我也是刚学这方面的东东,但愿本文能对初学者能有些帮助:).
下面是有关该小例子的配置文件.
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"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
default-lazy-init="true" default-autowire="no" default-dependency-check="none">
<bean id="configurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:/config/jdbc.properties"></property>
</bean>
<!-- JDBC DataSource -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClass}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.user}" />
<property name="password" value="${jdbc.password}" />
<property name="initialPoolSize" value="2" />
<property name="minPoolSize" value="2" />
<property name="maxPoolSize" value="10" />
<property name="acquireIncrement" value="2" />
<property name="maxIdleTime" value="2" />
<property name="maxStatements" value="10" />
<property name="autoCommitOnClose" value="false" />
</bean>
<bean id="inject.Processor" class="com.chinasunzone.xbase.core.spring.InjectProcessor" lazy-init="false">
</bean>
</beans>
applicationContext-ibatis.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"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
default-lazy-init="true" default-autowire="no" default-dependency-check="none">
<bean id="lazyDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<ref bean="dataSource"/>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="lazyDataSource"></ref>
</property>
</bean>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionAttributeSource">
<bean id="transactionAttributeSource"
class="com.ssi.xbase.AnnotationTransactionAttributeSource">
<property name="defaultRollbackFor" value="java.lang.Throwable" />
</bean>
</property>
<property name="transactionManager">
<ref local="transactionManager" />
</property>
</bean>
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:/config/SqlMapConfig.xml</value>
</property>
</bean>
<bean id="userDao" class="com.wwsi.dao.impl.UserDao">
<property name="dataSource">
<ref local="lazyDataSource"/>
</property>
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
<!-- Transaction AOP-Config For Service -->
<aop:config>
<aop:pointcut id="serviceTxPointcut" expression="execution(* com.ssi.service..I*Service.*(..))" />
<aop:advisor pointcut-ref="serviceTxPointcut" advice-ref="transactionInterceptor" order="1000" />
</aop:config>
</beans>
applicationContext-service.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-lazy-init="false">
<bean id="userService" class="com.ssi.service.impl.UserService">
</bean>
</beans>
application-web.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-lazy-init="false">
<bean id="dispatchAction"
class="com.opensymphony.xwork2.ActionSupport" singleton="false">
</bean>
<bean id="userAction" class="com.ssi.action.UserAction"
singleton="false">
</bean>
</beans>
只上传了除JAR包以外的程序部分.另附上所需JAR的截图,以便对照下载
- 大小: 15.5 KB
分享到:
相关推荐
struts2+spring+ibatis+mysql AOP日志管理,异常捕获 tomcat6.0+jdk1.6
struts2+spring+Ibatis框架包
有关Struts2+Spring+Hibernate和Struts2+Spring+Ibatis的整合实例demo 原创,完全基于eclipse开发
struts2+spring+ibatis的小demo
struts2+spring+ibatis项目实例
Struts2+Spring+Ibatis整合的简单人事管理系统 没分了,转载过来的,有需要的看看吧,我觉得不错~~
struts2+spring+ibatis整合项目实例
struts2 + spring + ibatis 整合例子,仓库:search.maven.org
自学两天ibatis后自己做的struts2+spring+ibatis+jquery ajax的登录注册
struts2+spring+ibatis+oracle+分页搜索+上传附件实例!完整版!
maven3+struts2+spring+ibatis,本来是用maven3+struts2+spring+hibernate但考虑到hibernate在多表级联查询的时候执行效率不高,所以改用性能更好不过sql比较麻烦的的ibatis,本项目只有登录和插入数据,仅供参考: ...
struts2+spring+ibatis
项目需要,可直接拿来用。本人花了一个礼拜心血搞的。有点,如果是发布到tomcat55上面可能要删掉验证xml的jar包才能正确运行
struts2+spring+ibatis 项目 入门使用 CRUD
是将struts2+spring3+iBATIS进行整合。
struts2+spring+ibatis做的增删改查的小例子 struts2+spring+ibatis SSI2整合 struts2+spring+ibatis增删改查 对初学者很有为、用
struts2 + spring + ibatis 实例 struts2 + spring + ibatis 实例 struts2 + spring + ibatis 实例 struts2 + spring + ibatis 实例 struts2 + spring + ibatis 实例
开发环境说明 ...本示例完整地结合Struts2+Spring2+iBatis2+MySQL5,演示了一个用户表的增、删、改、查。 想完整学习Struts2+Spring+iBatis的同仁,可以在这个例子中学习或模仿最基本也是最核心的技术要点。
用struts2+spring+ibatis实现了 增删查改翻页功能,使用的数据库是mysql, web服务器是tomcat
NULL 博文链接:https://hanqifeng.iteye.com/blog/840945