标签:def void 必须 tco str new user ice ram
在pom中
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
allication.yml中
eureka: client: serviceUrl: defaultZone: http://localhost:1000/eureka/ #注册中心地址 server: port: 2000 spring: application: name: user-server
主配置类
package cn.jiedada; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication @EnableEurekaClient public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); } }
controller
package cn.jiedada; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class UuserController { @RequestMapping("/") public String home() { return "Hello world"; } }
必须要开启服务器端才能使用客户端页面成功如下
标签:def void 必须 tco str new user ice ram
原文地址:https://www.cnblogs.com/xiaoruirui/p/11925717.html