2015-03-19 38 views
0
Caused by: org.springframework.beans.factory.BeanCreationException: 
Could not autowire field: private org.springframework.boot.actuate.metrics.GaugeService com.snapdeal.cpp.metrics.SDBootMetricPublisher.gaugeService; 
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type [org.springframework.boot.actuate.metrics.GaugeService] 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)} 

注意:在Spring引导的情况下,我在类级别使用此注释。当我使用弹簧启动运行项目时。它工作正常。但是当我在tomcat中部署它。我得到下面写入异常

@SpringBootApplication 
@EnableScheduling 
@EnableAspectJAutoProxy 
@ImportResource("classpath:spring/application-context*.xml") 
@ComponentScan({"com.cpp.*"}) 
public class CPPApplication{ 
public static void main(String[] args) { 
     SpringApplication application = new SpringApplication(CPPApplication.class); 
     application.setShowBanner(false); 
     application.run(args); 
} 

当我运行我的应用程序使用上面的主要方法。它工作正常。

但是当我删除此代码并尝试使用具有相同应用程序上下文的web.xml运行此应用程序时。它给错误。请帮忙!

回答

相关问题