创建Spring Boot微服务项目

创建一个测试用的微服务项目HelloWorld

创建项目

Alt text
Alt text
Alt text
Alt text

编写服务代码

@RestController
public class HelloWorld {

    @RequestMapping("/hello")
    public String Hello(@RequestParam String name){
        return "你好!" + name + ",这是一个微服务。";
    }
}

编辑配置文件application.properties:

spring.application.name=spring-cloud-provider-01
server.port=9000

Alt text

测试运行

Alt text

源码

Github仓库:https://github.com/sunweisheng/spring-cloud-example

猜你喜欢

转载自www.cnblogs.com/bluersw/p/11610693.html