【问题标题】:I'm getting an exception deploying a war in my box and it works fine in another one我在我的盒子里部署战争时遇到了一个异常,它在另一个盒子里运行良好
【发布时间】:2013-07-12 13:19:47
【问题描述】:

我有一个装有最新版本 Java (java/jdk1.7.0_25) 和 tomcat (apache-tomcat-7.0.42) 的 Linux 机器。当我部署战争时,我得到:

ERROR 2013-07-12 09:55:36,591: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'engageOrderConfig': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deliveryDtoToEngageRetailTransactionDelivery': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.company.engage.adapter.converter.customer.CustomerDTOToRetailTransactionCustomerExtension com.company.engage.order.adapter.converter.DeliveryDtoToEngageRetailTransactionDelivery.customerConverter; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.company.engage.adapter.converter.customer.CustomerDTOToRetailTransactionCustomerExtension] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

还有其他的……

事情是在另一个 linux 机器上部署这场战争,它开始时没有问题。

我尝试了几个版本的tomcat,我换成OpenJDK。另外,我从正在部署 jar 且没有错误的 linux 框中复制了 tomcat,并且我遇到了同样的错误。

任何人都可以对此有所了解吗?

编辑:Full Stacktrace

【问题讨论】:

  • 除了这场战争之外,这个工作的盒子是否还部署了其他东西?
  • 你能发布完整的堆栈跟踪吗?
  • No matching bean of type [com.starmount.engage.adapter.converter.customer.CustomerDTOToRetailTransactionCustomerExtension] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. 你确定这个 bean 可用吗?
  • 我添加了完整的堆栈跟踪。 @reto:是的,同样的战争在我旁边的 linux 中运行良好:(
  • @Kummo:.war 中是否有一个实现CustomerDTOToRetailTransactionCustomerExtension 的类?如果没有,另一个盒子是从哪里得到这个实现的?

标签: java linux tomcat deployment war


【解决方案1】:

将注解限定符添加到bean中的依赖项 示例:

public interface I{

}

public class IImpl1 implements I {
}

public class IImpl2 implements I {
}

class A {
//Without qualifier the exception that you see will be thrown
@Qualifier("impl1")

@Autowired
private I i;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    • 2018-04-20
    • 2020-10-19
    相关资源
    最近更新 更多