我在使用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>
我的控制器是
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;
}
}
TransactionServiceImpl
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 ;
}
}
TransaccionService
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:无法为资源元数据对bean类[com.zonagifts.web.service.TransaccionServiceImpl]进行内省:找不到它依赖的类
查看您的TransaccionServiceImpl类,您的类路径中可能缺少一些东西。
org.tempuri.GiftCardsSoapProxy
com.zonagifts.web.controller.LoginController
还有其他一些,但这两个给了我最大的停顿。
您可以验证这两个文件(或它们的jar文件)是否在已部署的类路径中?