Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cookanger opened this issue May 10, 2018 · 0 comments
Open

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

cookanger opened this issue May 10, 2018 · 0 comments

Comments

@cookanger
Copy link

cookanger commented May 10, 2018

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 中

@cookanger cookanger changed the title SHNo transactional EntityManager available SH项目 可查询不可修改新增删除- May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant