struts218+mybatis30+spring30全注解小例子.docx
《struts218+mybatis30+spring30全注解小例子.docx》由会员分享,可在线阅读,更多相关《struts218+mybatis30+spring30全注解小例子.docx(9页珍藏版)》请在冰豆网上搜索。
![struts218+mybatis30+spring30全注解小例子.docx](https://file1.bdocx.com/fileroot1/2022-11/15/2eb6c801-385d-42d1-999d-a6c809d888e9/2eb6c801-385d-42d1-999d-a6c809d888e91.gif)
struts218+mybatis30+spring30全注解小例子
所需架包
aopalliance.jar
asm-1.5.3.jar
aspectjrt.jar
aspectjweaver.jar
c3p0-0.9.1.jar
cglib-2.1_3.jar
mons.dbcp-1.2.2.osgi.jar
mons.logging-1.1.1.jar
mons.pool-1.5.3.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
freemarker-2.3.15.jar
junit-3.8.1.jar
log4j-1.2.15.jar
mybatis-3.0.3-SNAPSHOT.jar
mybatis-3.0.4.jar
mybatis-spring-1.0.0-RC2.jar
ognl-2.7.3.jar
ojdbc14.jar
org.springframework.aop-3.0.4.RELEASE.jar
org.springframework.asm-3.0.4.RELEASE.jar
org.springframework.context-3.0.4.RELEASE.jar
org.springframework.expression-3.0.4.RELEASE.jar
org.springframework.test-3.0.4.RELEASE.jar
org.springframework.web-3.0.4.RELEASE.jar
slf4j-api-1.5.10.jar
slf4j-log4j12-1.5.10.jar
spring-beans-3.0.4.RELEASE.jar
spring-core-3.0.4.RELEASE.jar
spring-jdbc-3.0.4.RELEASE.jar
spring-tx-3.0.4.RELEASE.jar
struts2-convention-plugin-2.1.8.1.jar
struts2-core-2.1.8.1.jar
struts2-spring-plugin-2.1.8.1.jar
struts-getterAndSetter-plugin.jar
xwork-core-2.1.6.jar
对应的配置文件
applicationContext.xml:
//www.springframework.org/schema/beans"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"xmlns:
jee="http:
//www.springframework.org/schema/jee"
xmlns:
tx="http:
//www.springframework.org/schema/tx"xmlns:
context="http:
//www.springframework.org/schema/context"
xmlns:
aop="http:
//www.springframework.org/schema/aop"
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/jee
http:
//www.springframework.org/schema/jee/spring-jee-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/context
http:
//www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName"default-lazy-init="true">
--定义受环境影响易变的变量-->
--标准配置-->
classpath:
com/medbri/mss/config/jdbc.properties
--使用annotation自动注册bean,并保证@Required,@Autowired的属性被注入-->
component-scanbase-package="com.medbri.mss"/>
--数据源配置,使用应用内的DBCP数据库连接池-->
--ConnectionInfo-->
--ConnectionPoolingInfo-->
com/medbri/mss/config/mybatis-config.xml"/>
--事务管理器配置,单数据源事务-->
--使用annotation定义事务-->
--annotation-driventransaction-manager="transactionManager"proxy-target-class="true"/>-->
configproxy-target-class="true">
advisorpointcut="execution(*com.medbri.mss.service..*Service.*(..))"
advice-ref="txAdvice"/>
config>
adviceid="txAdvice">
attributes>
methodname="get*"read-only="true"/>
methodname="find*"read-only="true"/>
methodname="query*"read-only="true"/>
methodname="is*"read-only="true"/>
methodname="*"propagation="REQUIRED"/>
attributes>
advice>
struts.xml
xmlversion="1.0"encoding="GBK"?
>
DOCTYPEstrutsPUBLIC
"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"
"http:
//struts.apache.org/dtds/struts-2.0.dtd">
--设置编码-->
--与spring集成-->
--指定默认的父包-->
value="medbri-default"/>
--设置convention插件默认的根包-->