开发者社区> 问答> 正文

TransactionRequiredException: Executing ?报错

数据库是Mysql 5.6

配置文件:

platform-appContext.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:lang="http://www.springframework.org/schema/lang"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:task="http://www.springframework.org/schema/task"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:cache="http://www.springframework.org/schema/cache"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:jpa="http://www.springframework.org/schema/data/jpa"

	xsi:schemaLocation="http://www.springframework.org/schema/beans    
            http://www.springframework.org/schema/beans/spring-beans.xsd   
            http://www.springframework.org/schema/context    
            http://www.springframework.org/schema/context/spring-context-4.0.xsd    
            http://www.springframework.org/schema/aop    
            http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
    		http://www.springframework.org/schema/lang
    		http://www.springframework.org/schema/lang/spring-lang-4.0.xsd
    		http://www.springframework.org/schema/jee
    		http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
    		http://www.springframework.org/schema/task
    		http://www.springframework.org/schema/task/spring-task-4.0.xsd
            http://www.springframework.org/schema/tx    
        	http://www.springframework.org/schema/tx/spring-tx.xsd
    		http://www.springframework.org/schema/cache 
    		http://www.springframework.org/schema/cache/spring-cache-4.0.xsd
    		http://www.springframework.org/schema/p
    		http://www.springframework.org/schema/spring-p-4.0.xsd
    		http://cxf.apache.org/jaxws 
    		http://cxf.apache.org/schemas/jaxws.xsd
    		http://www.springframework.org/schema/data/jpa 
    		http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">


	<bean
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:config/jdbc.properties</value>
			</list>
		</property>
	</bean>

	<!-- 配置启用注解扫描 -->
	<context:annotation-config />

	<!-- 配置扫描的根目录,在扫描的时候不用扫描Web Controller控制器 -->
	<context:component-scan base-package="net.hztech">
		<context:exclude-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

	<bean class="net.hztech.platform.env.spring.SpringContext" />

	<bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="${jdbc.driver}"></property>
		<property name="url" value="${jdbc.url}"></property>
		<!-- <property name="url" value="jdbc:mysql://${jdbc.server}:${jdbc.port}/${jdbc.database}?characterEncoding=${jdbc.encoding}"></property> -->
		<property name="username" value="${jdbc.username}"></property>
		<property name="password" value="${jdbc.password}"></property>
	</bean>

	<bean id="entityManagerFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceUnitName" value="DBS"></property>
		<property name="dataSource" ref="dataSource"></property>
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="database" value="${jdbc.dbtype}" />
				<property name="showSql" value="true" /> 
			</bean>
		</property>

		<property name="jpaProperties">
			<props>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
			</props>
		</property>
	</bean>

	<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor "/> 

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

	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

	<aop:aspectj-autoproxy proxy-target-class="true" />

	<jpa:repositories base-package="net.hztech.**.dao"
		factory-class="net.hztech.extra.data.repository.support.BaseRepositoryFactoryBean" 
		transaction-manager-ref="transactionManager" entity-manager-factory-ref="entityManagerFactory"/>

	<import resource="classpath:/appcontext/shiro-appContext.xml" />
	<import resource="classpath:/appcontext/quartz-appContext.xml" />
</beans>



back-webContext.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:lang="http://www.springframework.org/schema/lang" xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:task="http://www.springframework.org/schema/task" xmlns:cache="http://www.springframework.org/schema/cache"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans    
            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd   
            http://www.springframework.org/schema/context    
            http://www.springframework.org/schema/context/spring-context-4.0.xsd    
            http://www.springframework.org/schema/aop    
            http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
        	http://www.springframework.org/schema/mvc 
    		http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
    		http://www.springframework.org/schema/lang
    		http://www.springframework.org/schema/lang/spring-lang-4.0
    		http://www.springframework.org/schema/jee
    		http://www.springframework.org/schema/jee/spring-jee-4.0
    		http://www.springframework.org/schema/task
    		http://www.springframework.org/schema/task/spring-task-4.0
    		http://www.springframework.org/schema/cache 
    		http://www.springframework.org/schema/cache/spring-cache-4.0.xsd">

	<!-- 配置启用注解扫描 -->
	<context:annotation-config />
	
	<mvc:resources location="/bnormal/" mapping="/bnormal/**" />
	<mvc:resources location="/bmobile/" mapping="/bmobile/**" />

	<!-- 配置扫描的根目录,在扫描的时候不用扫描Web Controller控制器 -->
	<context:component-scan base-package="net.hztech.**.web.back" use-default-filters="false">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

	<!-- 配置拦截器 -->
	<mvc:interceptors>
		<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
		<bean
			class="org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor" />
	</mvc:interceptors>
	
	<mvc:annotation-driven>
		<mvc:argument-resolvers>  
			
        	<bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver">
        		<constructor-arg>
        			<bean class="net.hztech.extra.data.web.JsonSortHandlerMethodArgumentResolver">
					</bean>
        		</constructor-arg>
        		<property name="sizeParameterName" value="limit"></property>
        		<property name="oneIndexedParameters" value="true"></property>
        	</bean>  
    	</mvc:argument-resolvers>
	</mvc:annotation-driven>

	<bean
		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean>

	<bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
		<property name="messageConverters">
			<list>
				<bean
					class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
				</bean>
			</list>
		</property>
	</bean>

	<bean id="viewResolver"
		class="org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver">
		<constructor-arg index="0">
			<bean
				class="org.springframework.web.servlet.view.InternalResourceViewResolver">
				<property name="suffix" value=".jsp" />
			</bean>
		</constructor-arg>
		<property name="mobilePrefix" value="/bmobile"></property>
		<property name="tabletPrefix" value="/tablet"></property>
		<property name="normalPrefix" value="/bnormal"></property>
	</bean>

	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="maxUploadSize">
			<value>4096000000</value>
		</property>
		<property name="defaultEncoding">
			<value>UTF-8</value>
		</property>
	</bean>

	<bean id="localeResolver"
		class="org.springframework.web.servlet.i18n.CookieLocaleResolver" />

	<aop:aspectj-autoproxy proxy-target-class="true" />

</beans>



dao层代码:



package net.hztech.platform.core.dao;

import java.util.List;

import net.hztech.extra.data.domain.Limitable;
import net.hztech.extra.data.repository.BaseJpaRepository;
import net.hztech.platform.core.domain.User;
import net.hztech.platform.core.domain.UserStatus;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface UserDao extends BaseJpaRepository<User, Integer>
{

	public Page<User> findAll(Specification<User> spec, Pageable pageable);

	public List<User> findAll(Specification<User> spec, Limitable limitable);
	
	@Modifying
	@Query("update User bean set bean.name=?2, bean.gender=?3, bean.status=?4, bean.mobile=?5, bean.mailbox=?6, bean.remark=?7 where bean.id=?1")
	void updateMainInfo(Integer id, String name, String gender, UserStatus status, String mobile, String mailbox, String remark);
	
	@Query("select bean from User bean where bean.username=?1")
	public User findOne(String username);
	
}



service层代码:



package net.hztech.platform.core.service.impl;

import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.hztech.platform.core.dao.OrganizationDao;
import net.hztech.platform.core.dao.PositionDao;
import net.hztech.platform.core.dao.RoleDao;
import net.hztech.platform.core.dao.UserDao;
import net.hztech.platform.core.dao.UserGroupDao;
import net.hztech.platform.core.domain.Organization;
import net.hztech.platform.core.domain.Position;
import net.hztech.platform.core.domain.Role;
import net.hztech.platform.core.domain.User;
import net.hztech.platform.core.domain.UserStatus;
import net.hztech.platform.core.service.UserService;
import net.hztech.platform.secure.tools.PasswordEncrypter;
import net.hztech.utils.app.SessionUtils;

@Service
public class UserServiceImpl implements UserService
{

	@Autowired
	private UserDao userDao;
	
	@Autowired
	private PositionDao posDao;
	
	@Autowired
	private RoleDao roleDao;
	
	@Autowired
	private OrganizationDao orgDao;
	
	@Autowired
	private UserGroupDao groupDao;
	
	@Override
	@Transactional
	public void save(User user, List<Position> posistions) {
		if(user.getId()!=null&&user.getId()>0&&userDao.exists(user.getId())){
			throw new RuntimeException("已经存在主键为:"+ user.getId() + "的用户");
		}
		
		if(userDao.findOne(user.getUsername())!=null){
			throw new RuntimeException("已经存在用户名为:"+ user.getUsername()+ "的用户");
		}
		
		user.setSalt(PasswordEncrypter.generateSalt());
		user.setPassword(PasswordEncrypter.encryptPassword(user.getPassword(), user.getSalt()));
		user.setStatus(UserStatus.ACTIVATE);
		
		userDao.save(user);
		
		for(Position pos : posistions){
			pos.setRole(roleDao.findOne(pos.getRole().getCode()));
			pos.setOrg(orgDao.findOne(pos.getOrg().getCode()));
			pos.setUser(user);
		}
		
		posDao.save(posistions);
	}

	@Override
	@Transactional
	public void batchSave(String orgCode, String roleCode, String password,
			List<User> users) {
		Organization org = orgDao.findOne(orgCode);
		Role role = roleDao.findOne(roleCode);
		
		for(User user : users){
			if(user.getId()!=null&&user.getId()>0&&userDao.exists(user.getId())){
				throw new RuntimeException("已经存在主键为:"+ user.getId() + "的用户");
			}
			
			if(userDao.findOne(user.getUsername())!=null){
				throw new RuntimeException("已经存在用户名为:"+ user.getUsername()+ "的用户");
			}
			
			user.setSalt(PasswordEncrypter.generateSalt());
			user.setPassword(PasswordEncrypter.encryptPassword(password, user.getSalt()));
			user.setStatus(UserStatus.ACTIVATE);
			
			userDao.save(user);
			
			Position pos = new Position();
			
			pos.setOrg(org);
			pos.setRole(role);
			pos.setUser(user);
			pos.setSortNo(0);
			pos.setGroups(null);
			
			posDao.save(pos);
		}
	}

	@Override
	@Transactional
	public void update(User user, List<Position> posistions) {
		Integer id = user.getId();
		String name = user.getName();
		//userDao.updateMainInfo(id, name);
	}

	@Override
	@Transactional
	public void update(User user) {
		User old = userDao.findOne(user.getUsername());
		userDao.updateMainInfo(old.getId(), user.getName(), user.getGender(), user.getStatus(), user.getMobile(),user.getMailbox(), user.getRemark());
	}

	@Override
	@Transactional
	public void batchUpdate(List<User> users) {
		for(User user : users){
			update(user);
		}
	}

	@Override
	@Transactional
	public void delete(Integer id) {
		if(id.equals(1)){
			throw new RuntimeException("主键为:1的用户为系统默认管理员用户,不能删除");
		}
		
		userDao.delete(id);
	}

	@Override
	@Transactional
	public void batchDelete(List<Integer> ids) {
		for (Integer id : ids) {
			delete(id);
		}
	}

	@Override
	public User get(Integer id) {
		return userDao.findOne(id);
	}

	@Override
	public Page<Position> gridList(String text, String role, Integer ancestorId, boolean showDescendants, Pageable pageable) {
		Specification<Position> spec = new Specification<Position>(){

			@Override
			public Predicate toPredicate(Root<Position> root, CriteriaQuery<?> query,
					CriteriaBuilder cb) {
				
			    
				return null;
			}};
		
		return posDao.findAll(spec, pageable);
	}

	@Override
	public User findUser(String username) {
		// TODO Auto-generated method stub
		return userDao.findOne(username);
	}

	@Override
	public Position findDefaultPosition(String username) {
		// TODO Auto-generated method stub
		List<Position> poses = posDao.findAll(username);
		Position pos = poses.get(0);
		
		for(int i=1; i<poses.size(); i++){
			if(poses.get(i).getIsDefault()!=null&&poses.get(i).getIsDefault()){
				pos = poses.get(i);
			}
		}
		
 		return pos;
	}


	@Override
	public List<Position> userPositions() {
		User user = SessionUtils.getCurrentUser();
		
		List<Position> poses = posDao.findAll(user.getUsername());
		
		return poses;
	}
}



上面的代码中,执行save函数,成功,执行下面的代码就报错:
@Override
	@Transactional
	public void update(User user)

错误代码如下:


org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query
	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:413)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:223)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
	at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
	at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy55.updateMainInfo(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.zeroturnaround.javarebel.integration.util.ReloadingProxyFactory$ReloadingMethodHandler.invoke(SourceFile:74)
	at com.sun.proxy.$Proxy55.updateMainInfo(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.zeroturnaround.javarebel.integration.util.ReloadingProxyFactory$ReloadingMethodHandler.invoke(SourceFile:74)
	at com.sun.proxy.$Proxy55.updateMainInfo(Unknown Source)
	at net.hztech.platform.core.service.impl.UserServiceImpl.update(UserServiceImpl.java:122)
	at net.hztech.platform.core.web.back.UserController.update(UserController.java:81)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:111)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:806)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:729)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.mobile.device.DeviceResolverRequestFilter.doFilterInternal(DeviceResolverRequestFilter.java:60)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:178)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:106)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:142)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
	at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:71)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution$ModifyingExecution.doExecute(JpaQueryExecution.java:238)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:78)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:100)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:91)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:413)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:391)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)



请大神指教!!!



展开
收起
爱吃鱼的程序员 2020-06-12 14:19:31 553 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    这个问题解决了吗


    2020-06-12 14:19:49
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载