springbooot+springcloud初步使用及專案構建
阿新 • • 發佈:2018-11-09
springboot與springcloud初步使用
一、使用idea建立springboot專案
二、對應版本並匯入eureka依賴
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
三、在主類ClouddemoApplication中新增相應註解
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication @EnableEurekaClient public class ClouddemoClientApplication { public static void main(String[] args) { SpringApplication.run(ClouddemoClientApplication.class, args); } }
在application.yml中新增eureka的預設配置
server:
port: 8761
eureka:
client:
service-url:
defaultZone: http://localhost:${server.port}/eureka/
spring:
application:
name: eureka
點選執行並訪問http://localhost:8761