spring boot 微服务例子一
2021-07-03 14:05
标签:variable plugin conf val fir tap enc mave version import org.springframework.boot.SpringApplication; public static void main(String[] args) { } } } pom文件如下:使用idea的new---》spring initialr功能可以自动生成这个文件。 spring boot 微服务例子一 标签:variable plugin conf val fir tap enc mave version 原文地址:https://www.cnblogs.com/davidzhu/p/9622533.htmlpackage com.example.hello.demo;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
@RequestMapping(value="hello")
public class DemoApplication {
SpringApplication.run(DemoApplication.class, args);
@RequestMapping(value="/{firstName}/{lastName}",method = RequestMethod.GET)
public String hello(@PathVariable("firstName") String fName,@PathVariable("lastName") String lName){
return String.format("Hello zhukezhi :%s %s",fName,lName);
demo
spring-boot-starter-parent
spring-boot-starter
spring-boot-starter-test
spring-boot-starter-web
spring-boot-starter-web
spring-boot-maven-plugin
完成以后编译文件并使用内置的tomcat运行
http://localhost:8080/hello/julia/david/
返回字符串或者json串
文章标题:spring boot 微服务例子一
文章链接:http://soscw.com/index.php/essay/101294.html