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;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章