SpringCloud的服务接口基本等同于SpringBoot开发的api接口,只不过在springCloud需要将自己的服务注册到注册中心,通过网关统一访问路径
添加maven依赖
org.springframework.cloud
spring-cloud-starter-netflix-股票交易接口出售,eureka-client
org.springframework.cloud
spring-cloud-starter-netflix-zuul
启动类中添加@EnableEurekaClient注解
@SpringBootApplication
@EnableEurekaClient
@RestController
@RequestMapping('api')
public class MyServiceApplication {
public static void main(String[] args) {
SpringApplication.run(MyServiceApplication.class, args);
}
@RequestMapping('sayHello')
public String sayHello(){
return 'hello world';
}
}
#在注册中心显示的名字
spring.application.name=zuul-server
server.port=8762
#注册中心的地址
股票交易接口出售,eureka.client.service-url.defaultZone=http://localhost:8761/股票交易接口出售,eureka
#启用熔断的开关
feign.hystrix.enabled=true
文章为作者独立观点,不代表 股票程序化软件自动交易接口观点