pom.xml中增加
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
application.properties中增加
eureka.client.service-url.defaultZone=http://localhost:5000/eureka/
ConsumerClientApplication.java中增加
@EnableDiscoveryClient
package sun;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@ServletComponentScan
@EnableDiscoveryClient
public class ConsumerClientApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerClientApplication.class, args);
}
}
启动后,在Eureka中可以看到springbootService已注册