现在spring 2.0 配置升级到 spring 3.0自动注入,从ibatis升到mybatis。虽然辛苦,但是最有收获.
1.spring 3.0有stereotype类型,action对应用@Controller,service对应用@Service,dao对应用@Repository.
相应加载文件:
spring.xml
spring-mvc.xml
注:在加载action时要把service去掉,网上有说:
Spring MVC启动时的配置文件,包含组件扫描、url映射以及设置freemarker参数,让spring不扫描带有@Service注解的类。为什么要这样设置?因为servlet-context.xml与service-context.xml不是同时加载,如果不进行这样的设置,那么,spring就会将所有带@Service注解的类都扫描到容器中,等到加载service-context.xml的时候,会因为容器已经存在Service类,使得cglib将不对Service进行代理,直接导致的结果就是在service-context中的事务配置不起作用,发生异常时,无法对数据进行回滚。
2.如果事务用了“DataSourceTransactionManager”时,readOnly事务对oracle数据库是无效的.一样可以保存数据.
网上有说人到:
Oracle
Read Only 隔离级别只是支持Oracle Server,并不支持jdbc驱动,所以spring虽然设置了connection的readonly属性,但是oracle不支 持,不是spring的bug。
参考:
http://docs.oracle.com/cd/B19306_01/java.102/b14355/apxtips.htm
Transaction Isolation Levels and Access Modes
Read-only connections are supported by the Oracle server, but not by the Oracle JDBC drivers.