創建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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM