指定事务管理器 bean 后找不到匹配的编辑器或转换策略

我是新手,正在尝试创建一个 Spring5 MVC/Hibernate5 Web 应用程序,但是当我启动 Tomcat 时出现以下错误:


最初的问题与事务管理器有关,在添加事务管理器 bean 定义之前,应用程序启动正常但失败并显示错误消息,指出它无法创建事务线程。


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerController' defined in ServletContext resource [/WEB-INF/spring/store.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.sun.proxy.$Proxy210 implementing com.store.service.CustomerService,java.io.Serializable,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'com.store.service.CustomerServiceImpl' for property 'customerService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy210 implementing com.store.service.CustomerService,java.io.Serializable,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'com.store.service.CustomerServiceImpl' for property 'customerService': no matching editors or conversion strategy found

我的 web.xml :


<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xmlns="http://java.sun.com/xml/ns/javaee" 

         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 

                             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

                             id="WebApp_ID" version="2.5">


</web-app>


哈士奇WWW
浏览 123回答 1
1回答

aluckdog

我想在您的CustomerController课程中,您注入的不是接口,而是 的实现CustomerService,如下所示:public class CustomerController {&nbsp; &nbsp; @Autowired&nbsp; &nbsp; private CustomerServiceImpl customerService;}具体类是代理的,因此您应该将注入点指定为接口:public class CustomerController {&nbsp; &nbsp; @Autowired&nbsp; &nbsp; private CustomerService customerService;}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java