难道用了spring就需要try catch了么??没明白的你的意思

解决方案 »

  1.   

    难道用了spring就不需要try catch了么??
      

  2.   

    因为听说spring有较好的异常处理机制,但是它是不是只能在基于springMvc的web应用里面用呢?还有就是我上面的那个Applicationcontext,如果项目大了会很长的,我应该怎么把它分开能够方便开发和维护。
      

  3.   

    我在applicationcontext里配置事务时用了两个文件,前一个文件application-common.xml里配置事务
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref local="dataSource" />
    </property>
    <property name="mappingResources">
    <list>
    <value>com\vst\demo\user\entity\Userinfo.hbm.xml</value>
    <value>com\vst\demo\user\entity\Userrole.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    </bean>
    后面文件Application-user.xml
     <bean id="manager" parent="txProxyTemplate">
            <property name="target">
                <bean class="com.vst.demo.common.service.impl.BaseManager">
                    <property name="DAO"><ref bean="dao"/></property>
                </bean>
            </property>
        </bean>
    这样引用事务可不可以?
      

  4.   

    没有听说,异常处理机制要看你对开发的需要了,不过spring的AOP还是有很大的帮助的.
    不知道你说的是设么机制,,,呵呵
      

  5.   

    不好意思错了前面那个文件application-common.xml里是这样的:
     <bean id="txProxyTemplate" abstract="true"
            class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="transactionManager"><ref bean="transactionManager"/></property>
            <property name="transactionAttributes">
                <props>
                    <prop key="save*">PROPAGATION_REQUIRED</prop>
                    <prop key="remove*">PROPAGATION_REQUIRED</prop>
                    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
                </props>
            </property>
        </bean>
      

  6.   

    也就是说配置文件里的 <bean id="manager" parent="txProxyTemplate">的
    parent在另外一个xml文件里可以吗?