gpt4 book ai didi

java - Spring-MVC - 创建名称为 'procesarController' : Injection of autowired dependencies failed 的 bean 时出错

转载 作者:行者123 更新时间:2023-12-01 09:57:27 24 4
gpt4 key购买 nike

我在使用 spring 时遇到问题,在服务器中启动应用程序时出现此错误消息,请帮助,提前致谢!

错误信息

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'procesarController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zonagifts.web.service.TransaccionService com.zonagifts.web.controller.ProcesarController.transaccionService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TransaccionService' defined in file [C:\Users\Adolfo\Desktop\ZonacardEstableciemiento\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Webzonagifts\WEB-INF\classes\com\zonagifts\web\service\TransaccionServiceImpl.class]: Post-processing failed of bean type [class com.zonagifts.web.service.TransaccionServiceImpl] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.zonagifts.web.service.TransaccionServiceImpl] for resource metadata: could not find class that it depends on
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) [catalina.jar:7.0.27]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) [catalina.jar:7.0.27]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.27]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566) [catalina.jar:7.0.27]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556) [catalina.jar:7.0.27]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zonagifts.web.service.TransaccionService com.zonagifts.web.controller.ProcesarController.transaccionService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TransaccionService' defined in file [C:\Users\Adolfo\Desktop\ZonacardEstableciemiento\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Webzonagifts\WEB-INF\classes\com\zonagifts\web\service\TransaccionServiceImpl.class]: Post-processing failed of bean type [class com.zonagifts.web.service.TransaccionServiceImpl] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.zonagifts.web.service.TransaccionServiceImpl] for resource metadata: could not find class that it depends on
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
... 22 common frames omitted

我的servlet.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:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd">

<context:component-scan base-package="com.zonagifts.web" >
<context:include-filter type="aspectj" expression="com.zonagifts.*"/>
</context:component-scan>

<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="objectMapper" ref="objectMapper" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>


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


<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<mvc:resources mapping="/resources/**" location="/resources/" cache-period="604800" />
<mvc:view-controller path="/error" view-name="error" />

<bean id="viewResolver1" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="1" />
<property name="prefix" value="/WEB-INF/jsp/views/" />
<property name="suffix" value=".jsp" />
</bean>

<bean name="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper" />


<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="es" />
</bean>

</beans>

我的 Controller 是

package com.zonagifts.web.controller;

import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.zonagifts.web.domain.ResponseServicio;
import com.zonagifts.web.domain.Usuario;
import com.zonagifts.web.service.TransaccionService;
import com.zonagifts.web.util.Constantes;

@Controller
@RequestMapping("procesar")
public class ProcesarController {


@Autowired
private TransaccionService transaccionService;

private static Logger log = Logger.getLogger(LoginController.class);

@RequestMapping(value="activar",method=RequestMethod.POST)
public @ResponseBody ResponseServicio activarTarjeta(HttpSession sesion,String numeroTarjeta){

ResponseServicio responseServicio=new ResponseServicio();
Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
if(usuario != null){
String [] respuesta=transaccionService.activarTarjeta(numeroTarjeta, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), Constantes.TRANSACCION);
responseServicio.setRespuesta(respuesta[0]);
responseServicio.setCodigoOperacion(respuesta[1]);
responseServicio.setMensaje(respuesta[2]);
}
return responseServicio;
}

@RequestMapping(value="anular",method=RequestMethod.POST)
public @ResponseBody ResponseServicio anular(HttpSession sesion,String numeroTarjeta){

ResponseServicio responseServicio=new ResponseServicio();
Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
if(usuario != null){
String [] respuesta=transaccionService.anularTarjeta(numeroTarjeta, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), Constantes.TRANSACCION);
responseServicio.setRespuesta(respuesta[0]);
responseServicio.setCodigoOperacion(respuesta[1]);
responseServicio.setMensaje(respuesta[2]);
}
return responseServicio;
}


@RequestMapping(value="consumo",method=RequestMethod.POST)
public @ResponseBody ResponseServicio consumo(HttpSession sesion,String numeroTarjeta,String codigoSeguridad,String monto){

ResponseServicio responseServicio=new ResponseServicio();
Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
if(usuario != null){
String [] respuesta=transaccionService.consumirSaldo(numeroTarjeta, codigoSeguridad, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), monto, Constantes.TRANSACCION);
responseServicio.setRespuesta(respuesta[0]);
responseServicio.setCodigoOperacion(respuesta[1]);
responseServicio.setMensaje(respuesta[2]);
//responseServicio.setIdTransaccion(respuesta[3]);
}
return responseServicio;
}


@RequestMapping(value="saldo",method=RequestMethod.POST)
public @ResponseBody ResponseServicio saldo(HttpSession sesion,String numeroTarjeta){

ResponseServicio responseServicio=new ResponseServicio();
Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
if(usuario != null){
String [] respuesta=transaccionService.consultarSaldo(numeroTarjeta, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), Constantes.TRANSACCION);
responseServicio.setRespuesta(respuesta[0]);
responseServicio.setCodigoOperacion(respuesta[1]);
responseServicio.setMensaje(respuesta[2]);
}
return responseServicio;
}

}

事务服务Impl

package com.zonagifts.web.service;

import java.rmi.RemoteException;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.tempuri.GiftCardsSoapProxy;
import com.zonagifts.api.util.Util;
import com.zonagifts.web.controller.LoginController;

@Service
public class TransaccionServiceImpl implements TransaccionService {

private static GiftCardsSoapProxy giftCardsSoapProxy;

private static Logger log = Logger.getLogger(LoginController.class);

public String[] activarTarjeta(String numeroTarjeta, String codigoComercio,
String codigoTerminal, String idTransaccion) {

String token =tarjeta.concat(comercio).concat(terminal).concat(transaccion).concat(pass);
Object response=null;
try {
giftCardsSoapProxy=new GiftCardsSoapProxy();
response = giftCardsSoapProxy.activar_tarjeta(numeroTarjeta.trim(),
codigoComercio.trim(), codigoTerminal.trim(),
idTransaccion.trim(), token);

} catch (RemoteException e) {

e.printStackTrace();
}
String[] res = (String[]) response;
return res ;
}

public String[] anularTarjeta(String numeroTarjeta, String codigoComercio,
String codigoTerminal, String idTransaccion) {
String token =tarjeta.concat(comercio).concat(terminal).concat(transaccion).concat(pass);
Object response=null;
try {
giftCardsSoapProxy=new GiftCardsSoapProxy();
response = giftCardsSoapProxy.anular_tarjeta(numeroTarjeta.trim(),
codigoComercio.trim(), codigoTerminal.trim(),
idTransaccion.trim(), token);
} catch (RemoteException e) {

e.printStackTrace();
}
String[] res = (String[]) response;
//guardarTransaccionBD(tx);
return res ;
}

public String[] consumirSaldo(String numeroTarjeta, String codigoSeguridad,
String codigoComercio, String codigoTerminal, String montoConsumir,
String idTransaccion) {
String token =tarjeta.concat(codSeguridad).concat(comercio).concat(terminal).concat(monto).concat(transaccion).concat(pass);
Object response=null;
try {
giftCardsSoapProxy=new GiftCardsSoapProxy();
response = giftCardsSoapProxy.consumir_tarjeta(numeroTarjeta.trim(),
codigoSeguridad.trim(),codigoComercio.trim(),
codigoTerminal.trim(),montoConsumir.trim(), idTransaccion.trim(), token);
} catch (RemoteException e) {

e.printStackTrace();
}
String[] res = (String[]) response;
return res ;
}

public String[] consultarSaldo(String numeroTarjeta, String codigoComercio,
String codigoTerminal, String idTransaccion) {
String token =tarjeta.concat(comercio).concat(terminal).concat(transaccion).concat(pass);
Object response=null;
try {
giftCardsSoapProxy=new GiftCardsSoapProxy();
response = giftCardsSoapProxy.consultar_saldo(numeroTarjeta.trim(),
codigoComercio.trim(), codigoTerminal.trim(),
idTransaccion.trim(), token);
} catch (RemoteException e) {

e.printStackTrace();
}

String[] res = (String[]) response;
return res ;
}



}

交易服务

package com.zonagifts.web.service;

public interface TransaccionService {

String[] activarTarjeta(String numeroTarjeta,String codigoComercio,String codigoTerminal,String idTransaccion);

String[] anularTarjeta(String numeroTarjeta,String codigoComercio,String codigoTerminal,String idTransaccion);

String[] consumirSaldo(String numeroTarjeta,String codigoSeguridad,String codigoComercio,String codigoTerminal,String montoConsumir,String idTransaccion);

String[] consultarSaldo(String numeroTarjeta,String codigoComercio,String codigoTerminal,String idTransaccion);

}

最佳答案

因此您得到的最终异常如下:

java.lang.IllegalStateException: Failed to introspect bean class [com.zonagifts.web.service.TransaccionServiceImpl] for resource metadata: could not find class that it depends on

查看您的 TransaccionServiceImpl 类,您的类路径中可能缺少一些内容...

  • org.tempuri.GiftCardsSoapProxy
  • com.zonagifts.web.controller.LoginController

还有其他的,但这两个是最让我犹豫的。

您能否验证这两个文件(或其 jar 文件)是否位于您部署的类路径中?

关于java - Spring-MVC - 创建名称为 'procesarController' : Injection of autowired dependencies failed 的 bean 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37077494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com