spring-boot之helloWorld

需要添加一个类,然后写一个方法,注释使用RestController

@RestController

public class HelloWorld {

@RequestMapping("/")

public String sayHelloWorld(){

return "hello world!";

}

}

之后通过springApplicationMain中的类run启动即可

之后浏览器访问:http://127.0.0.1:8081/就可以看到hello world了

解释RestController注解的作用是返回json格式的数据

 

猜你喜欢

转载自lsj626472785.iteye.com/blog/2343740