action 中怎么执行多个service操作
action 中如何执行多个service操作
这多个service分别执行多个更新操作
------解决思路----------------------
上两个例子就知道了:
------解决思路----------------------
一个一个注入service,唯一的优点就是可以偷懒。但如果后期有改动,你会很头疼;
理由:1:依赖多个service,一旦某一个有改动,就可能影响你的这个业务;
2:失误控制会很乱;
建议你:单独写一个service,把需要的功能代码单独写出来,看起来费劲,但后期你就轻松多了;
曾经遇到一些项目,开发很混乱,各个模块依赖严重,后期上线时候,一旦该一个bug,就会为很多模块埋线隐患,结果,就在焦油坑里爬了很久...
------解决思路----------------------
<!-- Action -->
<bean id="messageboardaction" class="com.hhcts.spicture.action.MessageBoardAction" scope="prototype">
<property name="messageboardservice" ref="messageboardservice"></property>
<property name="userservice" ref="userservice"></property>
</bean>
这多个service分别执行多个更新操作
------解决思路----------------------
上两个例子就知道了:
<!-- BookType注入 -->
<bean id="BookTypeServiceTarget" class="com.dwg.serviceImpl.BookTypeServiceImpl" scope="singleton">
<property name="booktypedao" ref="BookTypeDAO" />
</bean>
<bean id="BookTypeService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target">
<ref local="BookTypeServiceTarget"/>
</property>
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- LoanInfo注入 -->
<bean id="LoanInfoServiceTarget" class="com.dwg.serviceImpl.LoanInfoServiceImpl" scope="singleton">
<property name="Loaninfodao" ref="LoanInfoDAO" />
</bean>
<bean id="LoanInfoService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target">
<ref local="LoanInfoServiceTarget"/>
</property>
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
------解决思路----------------------
一个一个注入service,唯一的优点就是可以偷懒。但如果后期有改动,你会很头疼;
理由:1:依赖多个service,一旦某一个有改动,就可能影响你的这个业务;
2:失误控制会很乱;
建议你:单独写一个service,把需要的功能代码单独写出来,看起来费劲,但后期你就轻松多了;
曾经遇到一些项目,开发很混乱,各个模块依赖严重,后期上线时候,一旦该一个bug,就会为很多模块埋线隐患,结果,就在焦油坑里爬了很久...
------解决思路----------------------
<!-- Action -->
<bean id="messageboardaction" class="com.hhcts.spicture.action.MessageBoardAction" scope="prototype">
<property name="messageboardservice" ref="messageboardservice"></property>
<property name="userservice" ref="userservice"></property>
</bean>