spring-boot hello world 程序
2018-04-27 本文已影响0人
lisa_777
环境:win 10,jdk8,eclipse(上官网搜索最新版本下载),maven
步骤:
1.启动Eclipse,进入help->eclipse marketplace ->popular ->STS 安装

注意:mars版本的Eclipse不支持,即使可以安装STS,在后续操作中也无法创建springboot项目
2.新建项目- file-> new->project-> Spring Starter Project

注意:首次建项目,需要新建Project->Spring Boot ->Spring Starter Project,如下图所示

3.新建项目过程,如图


此时,项目已经创建成功了,容易出现问题,pom.xml文件报错,具体查看报错的信息,提示哪些jar包下载错误,手动去删除C:\Users\Administrator.m2\repository下对应的jar包即可,无需删除整个仓库
再点击项目,右键,maven-update maven 即可.
4.项目结构

5.helloworld程序
--新建HelloController,如上图所在位置
--代码如下

6.运行Demo2Application.java--名字根据起的项目名不一样而改变.

7.运行成功的结果:

8.打开浏览器:localhost:8080/hello,如显示下图,表示第一个spring_boot 运行成功啦~~
