ssh:org.springframework.beans.factory.BeanCreationException: Error creating bean

本文介绍了一个常见的SSH框架下的错误,并提供了解决方案。错误源于依赖冲突导致无法创建bean,通过调整pom.xml文件中的依赖版本可以解决问题。

整合ssh框架下有以下报错。

Type Exception Report

Message Unable to instantiate Action, loginAction, defined for 'login1' in namespace '/'Error creating bean with name 'loginAction' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.sun.proxy.$Proxy37 implementing com.dhu.service.TbManagerService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'com.dhu.service.TbManagerServiceImpl' for property 'tbManagerService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy37 implementing com.dhu.service.TbManagerService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'com.dhu.service.TbManagerServiceImpl' for property 'tbManagerService': no matching editors or conversion strategy found

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

Unable to instantiate Action, loginAction,  defined for 'login1' in namespace '/'Error creating bean with name 'loginAction' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.sun.proxy.$Proxy37 implementing com.dhu.service.TbManagerService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'com.dhu.service.TbManagerServiceImpl' for property 'tbManagerService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy37 implementing com.dhu.service.TbManagerService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'com.dhu.service.TbManagerServiceImpl' for property 'tbManagerService': no matching editors or conversion strategy found
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:319)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:400)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:500)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

解决方法:如果你的注解什么的,都对。也没有写错,漏写依赖,死活报这个错,那么建议你使用我这个方法,修改你的pom.xml文件。因为这个很多,不是你自己代码的原因。ssh框架下有的依赖库是相互冲突的,导致无法生成相应bean。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mrchen.ssh</groupId>
  <artifactId>ssh_crm</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  
  <dependencies>
  <!-- hibernate5.2.10.final导包 -->
  	<!-- https://mvnrepository.com/artifact/antlr/antlr -->
	<dependency>
	    <groupId>antlr</groupId>
	    <artifactId>antlr</artifactId>
	    <version>2.7.7</version>
	</dependency>
  
  	<!-- https://mvnrepository.com/artifact/com.fasterxml/classmate -->
	<dependency>
	    <groupId>com.fasterxml</groupId>
	    <artifactId>classmate</artifactId>
	    <version>1.3.0</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/dom4j/dom4j -->
	<dependency>
	    <groupId>dom4j</groupId>
	    <artifactId>dom4j</artifactId>
	    <version>1.6.1</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.hibernate.common/hibernate-commons-annotations -->
	<dependency>
	    <groupId>org.hibernate.common</groupId>
	    <artifactId>hibernate-commons-annotations</artifactId>
	    <version>5.0.1.Final</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
	<dependency>
	    <groupId>org.hibernate</groupId>
	    <artifactId>hibernate-core</artifactId>
	    <version>5.2.10.Final</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.1-api -->
	<dependency>
	    <groupId>org.hibernate.javax.persistence</groupId>
	    <artifactId>hibernate-jpa-2.1-api</artifactId>
	    <version>1.0.0.Final</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.jboss/jandex -->
	<dependency>
	    <groupId>org.jboss</groupId>
	    <artifactId>jandex</artifactId>
	    <version>2.0.3.Final</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
	<dependency>
	    <groupId>org.javassist</groupId>
	    <artifactId>javassist</artifactId>
	    <version>3.20.0-GA</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.jboss.logging/jboss-logging -->
	<dependency>
	    <groupId>org.jboss.logging</groupId>
	    <artifactId>jboss-logging</artifactId>
	    <version>3.3.0.Final</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.jboss.spec.javax.transaction/jboss-transaction-api_1.2_spec -->
	<dependency>
	    <groupId>org.jboss.spec.javax.transaction</groupId>
	    <artifactId>jboss-transaction-api_1.2_spec</artifactId>
	    <version>1.0.1.Final</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-jpamodelgen -->
	<dependency>
	    <groupId>org.hibernate</groupId>
	    <artifactId>hibernate-jpamodelgen</artifactId>
	    <version>5.2.10.Final</version>
	    <scope>provided</scope>
	</dependency>
  	
  	<!-- mysql-jdbc驱动 -->
  	<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
	<dependency>
	    <groupId>mysql</groupId>
	    <artifactId>mysql-connector-java</artifactId>
	    <version>5.1.39</version>
	</dependency>
  	
  	<!-- struts-2.3.24导包 -->
  	
  	<!-- https://mvnrepository.com/artifact/asm/asm -->
	<dependency>
	    <groupId>asm</groupId>
	    <artifactId>asm</artifactId>
	    <version>3.3</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/asm/asm-commons -->
	<dependency>
	    <groupId>asm</groupId>
	    <artifactId>asm-commons</artifactId>
	    <version>3.3</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/asm/asm-tree -->
	<dependency>
	    <groupId>asm</groupId>
	    <artifactId>asm-tree</artifactId>
	    <version>3.3</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
	<dependency>
	    <groupId>commons-fileupload</groupId>
	    <artifactId>commons-fileupload</artifactId>
	    <version>1.3.1</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
	<dependency>
	    <groupId>commons-io</groupId>
	    <artifactId>commons-io</artifactId>
	    <version>2.2</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
	<dependency>
	    <groupId>org.apache.commons</groupId>
	    <artifactId>commons-lang3</artifactId>
	    <version>3.2</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
	<dependency>
	    <groupId>org.apache.logging.log4j</groupId>
	    <artifactId>log4j-api</artifactId>
	    <version>2.2</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
	<dependency>
	    <groupId>org.apache.logging.log4j</groupId>
	    <artifactId>log4j-core</artifactId>
	    <version>2.2</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/ognl/ognl -->
	<dependency>
	    <groupId>ognl</groupId>
	    <artifactId>ognl</artifactId>
	    <version>3.0.6</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
	<dependency>
	    <groupId>org.apache.struts</groupId>
	    <artifactId>struts2-core</artifactId>
	    <version>2.3.24</version>
	</dependency>
	
  	<!-- https://mvnrepository.com/artifact/org.apache.struts.xwork/xwork-core -->
	<dependency>
	    <groupId>org.apache.struts.xwork</groupId>
	    <artifactId>xwork-core</artifactId>
	    <version>2.3.24</version>
	</dependency>
  	
 <!-- struts2整合spring插件包 -->
  	<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-spring-plugin -->
	<dependency>
	    <groupId>org.apache.struts</groupId>
	    <artifactId>struts2-spring-plugin</artifactId>
	    <version>2.3.24</version>
	</dependency>
  	
 <!-- spring-4.3.9导包 -->
  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-beans</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>

  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-context</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-core</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-expression -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-expression</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.apache.log4j/com.springsource.org.apache.log4j -->
	<dependency>
	    <groupId>org.apache.log4j</groupId>
	    <artifactId>com.springsource.org.apache.log4j</artifactId>
	    <version>1.2.15</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.apache.commons/com.springsource.org.apache.commons.logging -->
	<dependency>
	    <groupId>org.apache.commons</groupId>
	    <artifactId>com.springsource.org.apache.commons.logging</artifactId>
	    <version>1.1.1</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-web</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-aop</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-aspects</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.aopalliance/com.springsource.org.aopalliance -->
	<dependency>
	    <groupId>org.aopalliance</groupId>
	    <artifactId>com.springsource.org.aopalliance</artifactId>
	    <version>1.0.0</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.aspectj/com.springsource.org.aspectj.weaver -->
	<dependency>
	    <groupId>org.aspectj</groupId>
	    <artifactId>com.springsource.org.aspectj.weaver</artifactId>
	    <version>1.6.8.RELEASE</version>
	</dependency>
	
	
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-jdbc</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
	
  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-tx</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
	<dependency>
	    <groupId>com.mchange</groupId>
	    <artifactId>c3p0</artifactId>
	    <version>0.9.5.2</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-orm</artifactId>
	    <version>4.3.9.RELEASE</version>
	</dependency>
	  	
  	<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-test</artifactId>
	    <version>4.3.9.RELEASE</version>
	    <scope>test</scope>
	</dependency>
  	
 <!-- 标签库导包 -->
  	<!-- https://mvnrepository.com/artifact/taglibs/standard -->
	<dependency>
	    <groupId>taglibs</groupId>
	    <artifactId>standard</artifactId>
	    <version>1.1.2</version>
	</dependency>
  	
  	<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
	<dependency>
	    <groupId>javax.servlet</groupId>
	    <artifactId>jstl</artifactId>
	    <version>1.2</version>
	</dependency>

</dependencies>
</project>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值