Springboot入门(一)Hello Springboot

来源:互联网 发布:淘宝小当家水浒卡 编辑:程序博客网 时间:2024/06/15 13:36

eclipse

在线安装springboot插件

(推荐在线安装,之前也有尝试离线安装,时间并不比在线安装短多少,而且有时候还会出现安装不上的情况,所以不是很建议离线安装)
1.Help -> Eclipse Marketplace…
2.选择“Popular”标签去查找spring Tool Suite (STS) for Eclipse插件,找到后在线安裝
这里写图片描述
加载时间稍长,也还好,后面就是confirm—accept 完成之后会被要求重启。安装成功的话,window—show view ——other ——可以看到有spring文件夹。
这里写图片描述

离线安装springboot插件

1.工具下载地址:
Spring Tool Suite:https://spring.io/tools/sts/all
注意你的ecplise版本
这里写图片描述
2.安装步骤:

2.1 在Eclipse中打开Help —> Install New Sofware…

2.2 点击Add——找到你下载的路径
这里写图片描述
后面基本都是下一步,就不啰嗦了

IDEA

还没尝试,暂时不写,过几天尝试了再写。

Hello Springboot

创建第一个Springboot项目

File——new——other
这里写图片描述
这里写图片描述
下面注意,刚开始如果你没有其他环境,只选择下面图中的web即可,其他的不要勾选,不然你的项目可能因为一些环境跟依赖关系,不能正常运行。
这里写图片描述
创建项目过程中,我出现了两个问题,可以大体浏览一下。
http://blog.csdn.net/danfengw/article/details/76945496
http://blog.csdn.net/danfengw/article/details/76984728

运行

创建java文件,代码如下:

@RestControllerpublic class HelloWorld {    @RequestMapping(value="/hello",method=RequestMethod.GET)    public String say() {        return "Hello Springboot";    }}

run——spring Boot application
运行之后在你的浏览器中输入:http://localhost:8080/hello
这里写图片描述