以前用老框架是struts + jdbc + ibatis(只用到sql模板)在数据库连接在自己定义的文件provider.xml中写的如下:
<access name="local">
<prop name="db.jdbc.url">jdbc:jtds:sqlserver://localhost:1433;DatabaseName=fh_mhw;SelectMethod=cursor</prop>
<prop name="db.jdbc.user">sa</prop>
<prop name="db.jdbc.password">sa</prop>
<prop name="db.jdbc.driver">net.sourceforge.jtds.jdbc.Driver</prop>
</access>
但是事务必须手动处理
public static void insert(Object object) {
// TODO Auto-generated method stub
    DBTable dbtable = DBTable.getInstance("local");
DataStore Datastore = (DataStore) DataStoreMan.getInstance().getDataStore("local");
try {
DBRecord dbrecord = DBField.describeInstance(object);
//事务开始
Datastore.begin();
if (dbrecord != null) {
dbtable.insert(dbrecord.getString("DB_Table_Name"), dbrecord);
} else {
System.out.println("列值为空无法更新数据!");
}
//事务提交
Datastore.commitAndResume();
} catch (DBException e) {
//事务回滚
Datastore.rollbackAndResume();
e.printStackTrace();
} finally {
DataStoreMan.getInstance().getDataStore("local").close(true);
}
}
现在想加入spring来进行事务管理,不能可以不?我安网上写的配置好几次都不成功?我是这样的配置的
dao类如下:
public interface ExampleDAO  {public void insertExample(Example example);
public void updateExample(Example example);
public void deleteExample(Example example);}
dao实现类如下:
public class ExampleDAOImpl implements ExampleDAO { private ExampleDAO ExampleDAO;

/**
 * @return the exampleDAO
 */
public ExampleDAO getExampleDAO() {
return ExampleDAO;
} /**
 * @param exampleDAO the exampleDAO to set
 */
public void setExampleDAO(ExampleDAO exampleDAO) {
ExampleDAO = exampleDAO;
} public void deleteExample(Example example) {
// TODO Auto-generated method stub
DB.delete(example);
} public void insertExample(Example example) throws WhcaException{
DB.insert(example);
} public void updateExample(Example example) {
// TODO Auto-generated method stub
DB.update(example);
}
}
其中DB类就是工具类如下:
public static void update(Object object) {
// TODO Auto-generated method stub
    DBTable dbtable = DBTable.getInstance("local");
try {
DBRecord dbrecord = DBField.describeInstance(object);
if (dbrecord != null) {
dbtable.insert(dbrecord.getString("DB_Table_Name"), dbrecord);
} else {
System.out.println("列值为空无法更新数据!");
}
} catch (DBException e) {
e.printStackTrace();
} finally {
DataStoreMan.getInstance().getDataStore("local").close(true);
}
}
struts-config.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "struts-config_1_2.dtd"><struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="loginForm" type="com.infoer.struts.actionform.LoginForm" />
    <form-bean name="gnmkForm" type="com.infoer.struts.actionform.GnmkForm" />
    <form-bean name="exampleForm" type="com.infoer.example.struts.actionform.ExampleForm" />
  </form-beans>  <global-exceptions>   </global-exceptions>

  <global-forwards>
<forward name="error" path="/pages/app/error.jsp" />
  </global-forwards>

  <action-mappings >
 <action path="/login"
    type="org.springframework.web.struts.DelegatingActionProxy"
    name="loginForm" scope="request" input="/form/login.jsp"
    parameter="method" validate="false">
<forward name="login_success" path="/pages/app/mainframe.jsp"
redirect="false" />
<forward name="login_failure" path="/index.jsp" redirect="false" />
 </action>
 <action path="/gnmk"
    type="org.springframework.web.struts.DelegatingActionProxy"
    name="gnmkForm" scope="request" input="/form/login.jsp"
    parameter="method" validate="false">
    <forward name="list" path="/pages/gnmk/gnmkList.jsp"
redirect="false" />
<forward name="edit" path="/pages/gnmk/gnmkForm.jsp"
redirect="false" />
 </action>
 <action path="/example"
    type="org.springframework.web.struts.DelegatingActionProxy"
    name="exampleForm" scope="request" input="/pages/example/gnmkList.jsp"
    parameter="method" validate="false">
    <forward name="list" path="/pages/example/exampleList.jsp"
redirect="false" />
<forward name="edit" path="/pages/example/exampleForm.jsp"
redirect="false" />
 </action>
 <action path="/exampletest"
    type="org.springframework.web.struts.DelegatingActionProxy"
    name="exampleForm" scope="request" input="/pages/example/gnmkList.jsp"
    parameter="method" validate="false">
    <forward name="list" path="/pages/example/exampleList.jsp"
redirect="false" />
<forward name="edit" path="/pages/example/exampleForm.jsp"
redirect="false" />
 </action>  
  </action-mappings> <message-resources
parameter="com.infoer.struts.ApplicationResources" />
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value=" /WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
</struts-config>applicationContext.xml如下:
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>    <bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED,-RuntimeException</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>  
<bean name="/login" class="com.infoer.system.struts.action.LoginAction"
singleton="false">
<property name="exampleService">
<ref bean="ExampleService" />
</property>
</bean>    <bean name="/logout" class="com.infoer.system.struts.action.LogoutAction"
singleton="false">
</bean>
<bean name="/example" class="com.infoer.example.struts.action.ExampleAction"
singleton="false">
<property name="exampleDAO">
<ref bean="ExampleDAO" />
</property>
<property name="exampleTestDAO">
<ref bean="ExampleTestDAO" />
</property>
</bean>
<bean name="/exampletest" class="com.infoer.example.struts.action.ExampleTestAction"
singleton="false">
<property name="exampleTestDAO">
<ref bean="ExampleTestDAO" />
</property>
</bean>     <bean id="ExampleDAO" class="com.infoer.example.dao.impl.ExampleDAOImpl"></bean>    
    <bean id="ExampleTestDAO" class="com.infoer.example.dao.impl.ExampleTestDAOImpl"></bean>  </beans>
这个文件不知道如何配置,网上例子基本上都要配置dataSource,但我不需要.请高手帮忙,如何配置才可以?