Java之SpringCloud Eurka註冊錯誤解決方案

學習SpringCloud時,在Eurka中註冊時出現的錯誤:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-04 11:15:19.703 ERROR 34860 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
 
***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Field discoveryClient in cn.itcast.consumer.web.ConsumerController required a bean of type 'com.netflix.discovery.DiscoveryClient' that could not be found.
 
The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)
 
 
Action:
 
Consider defining a bean of type 'com.netflix.discovery.DiscoveryClient' in your configuration.
 

錯誤代碼:

import com.netflix.discovery.DiscoveryClient;
 
@Autowired
private DiscoveryClient discoveryClient;

錯誤原因:導錯瞭jar包

正確代碼:

import org.springframework.cloud.client.discovery.DiscoveryClient;
 
 
@Autowired
private DiscoveryClient discoveryClient;

到此這篇關於Java之SpringCloud Eurka註冊錯誤解決方案的文章就介紹到這瞭,更多相關Java之SpringCloud Eurka註冊錯誤內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: