安装sts插件
Help --> eclipse Marketplace --> search --> Spring Tool Suite --> Install
安装后需要重启eclipse才能生效
创建springboot项目
File --> New --> Other --> Spring Boot --> Spring Starter Project --> Finish
目录结构如下:
运行hello world
* 项目(右键) --> new --> Package --> controller --> 项目(右键) --> Refresh
* controller包(右键) --> new --> Class --> Application
-------------------------------------------------------
package com.hrjlk.controller;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
* controller包(右键) --> new --> Class --> HelloWorld
-------------------------------------------------------------------------------
package com.hrjlk.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorld {
@RequestMapping("/hello")
public String Hello(String name) {
return "Hello " + name;
}
}
* 项目(右键) --> new --> Package --> demo --> 项目(右键) --> Refresh
* 运行Application.java
* 浏览器访问 --> http://localhost:8080/hello?name=World --> 输出"Hello World"