Skip to content

SH项目 可查询不可修改新增删除- #15

Open
@cookanger

Description

1.ApplicationContext_bean.xml中,去掉对controller的扫描

<context:component-scan base-package="com.trans">
    <context:exclude-filter type="annotation" ="org.springframework.stereotype.Controller" />
</context:component-scan>

2.ApplicationContext_mvc.xml中,去掉对 service的扫描,加入对controller的扫描

<context:component-scan base-package="cn.easyproject.easyee">
   	<context:include-filter type="annotation" ="org.springframework.stereotype.Controller"/>
   	<context:exclude-filter type="annotation" ="org.springframework.stereotype.Service"/>
   </context:component-scan>

3.将以下代码移至 applicationContext.xml中

<!--  3. TransactionManager -->
	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory"></property>
	</bean>

	<tx:annotation-driven transaction-manager="transactionManager" />

	<!-- 开启 Schema 式事务管理 -->
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="insert*" propagation="REQUIRED"/>
			<tx:method name="add*"/>
			<tx:method name="save*"/>
			<tx:method name="new*"/>
			<tx:method name="create*"/>
			<tx:method name="del*"/>
			<tx:method name="remove*"/>
			<tx:method name="destory*"/>
			<tx:method name="update*"/>
			<tx:method name="edit*"/>
			<tx:method name="change*"/>
			<tx:method name="move*"/>
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<!-- AOP 将通知织入切点表达式指定的方法-->
	<aop:config>
		<!--  SYS 事务 AOP -->
		<aop:advisor advice-ref="txAdvice"
					 pointcut="execution(* cn.easyproject.easyee.sh.sys.service..*.*(..))" />
		<!-- 自定义模块事务配置.... -->
	</aop:config>

必须配置在 applicationContext.xml 中

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions