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運行此應用程序時。它給錯誤。請幫忙!