spring boot初体验,推荐使用idea来进行开发spring boot,idea是最好的Java开发工具之一(谦虚,可能没有之一)。
新建一个项目
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller//因为pom文件中添加了spring web的依赖,所以这些注解都能使用
public class HelloController {
@RequestMapping(value = "/hello",method = RequestMethod.GET)//映射器
@ResponseBody//以json形式返回到页面
public String hello(){
return "hello, Spring Boot";
}
}
因为spring boot内嵌tomcat服务器,所以我们直接启动就好了。
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- igbc.cn 版权所有 湘ICP备2023023988号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务