数据库没有反应,没有自动建表,但是sql输出了,怎么回事啊
调用代码:
@Test public void testInitData(){
context = new ClassPathXmlApplicationContext("applicationContext.xml");
IUserDao dao = (IUserDao) context.getBean("UserDAOProxy");
User user = new User();
user.setUsername("lunan");
user.setGender("man");
user.setAddress("beijing");
user.setPhone("911");
user.setEmail("[email protected]");
user.setInfo("abc");
user.setCreateDate(new Date());
try {
dao.saveUser(user);
System.out.println("保存 user ---> ok。");
} catch (DataAccessException e) {
// e.printStackTrace();
// 发现异常
System.out.println("DataAccessException can't save。");
}
}Spring DAO事务配置如下:<bean id="UserDAOProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="UserDaoTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>

解决方案 »

  1.   

    我的资源里有本spring2.5教程,介绍的很详细,配有大量图片、源码说明。有需要的朋友可以去看看
      

  2.   

    LZ 你保存时 没进行事物提交  
    <aop:config>
    <aop:pointcut id="bizMethods"
    expression="execution(* cn.com.yyaccp.service.*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
    </aop:config楼主我上传了一个spring的文档上去 很好 你去看下