zoukankan      html  css  js  c++  java
  • 错误之Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined

    HTTP Status 500 - Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined


    type Exception report

    message Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined

    description The server encountered an internal error that prevented it from fulfilling this request.

    exception

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:943)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:822)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    

    root cause

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:638)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1159)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:282)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    	org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:334)
    	org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:252)
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    	org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:646)
    	com.neuedu.service.CustomermanagerServices$$EnhancerByCGLIB$$a0105894.deleteContact(<generated>)
    	com.neuedu.controller.CustomerManagerController.deleteContact(CustomerManagerController.java:102)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	java.lang.reflect.Method.invoke(Unknown Source)
    	org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
    	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
    	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748)
    	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
    	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:822)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    

    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.67 logs.


    Apache Tomcat/7.0.67

    原因:从No bean named 'transactionManager' is defined看出是事物出了问题,在bean中没有配置事物

    解决方案:在spring的配置文件中配置如下信息

     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
              <property name="dataSource" ref="comboPooledDataSource"></property>
      </bean>

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

  • 相关阅读:
    Django 常见问题
    post和get的区别
    Django 基础学习笔记二
    Django 中的分页器
    Python 微服务框架 Nameko 微服务通信(RabbitMQ)
    《大数据白皮书 2020.12》解读
    练习Div+Css
    利用JAVAScript调用WebService
    统计在线人数和历史访问人数
    自己写的一个DBHelper
  • 原文地址:https://www.cnblogs.com/TYDBLOG/p/7598701.html
Copyright © 2011-2022 走看看