方法一
安装 STS 插件
安装插件导向窗口完成后, 在 eclipse 右下角将会出现安装插件的进度, 等插件安装完成后重启 eclipse 生效
新建 spring boot 项目
项目启动
方法二
1. 创建 Maven 项目
2. 选择项目类型
3. 选择项目
4. 编写项目组和名称 - finish 即可
5. 修改 pom.xml 文件
- <!-- spring boot 基本环境 -->
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.0.2.RELEASE</version>
- </parent>
6.pom.xml 中添加依赖
- <!--web 应用基本环境配置 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-Web</artifactId>
- </dependency>
7.pom.xml 中添加编译插件
- <build>
- <plugins>
- <!-- spring-boot-maven-plugin 插件就是打包 spring boot 应用的 -->
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins
- </build>
8. 基础包和类
9. 创建 resources 文件夹和 application.properties 文件
10.App.java
- package com.springboot.springbootDemo;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- @SpringBootApplication
- public class App
- {
- public static void main( String[] args )
- {
- SpringApplication.run(App.class, args);
- }
- }
11.HelloController.java
- package com.springboot.springbootDemo.controller;
- import org.springframework.Web.bind.annotation.RequestMapping;
- import org.springframework.Web.bind.annotation.RestController;
- @RestController
- @RequestMapping("hello2")
- public class HelloController {
- @RequestMapping("")
- public String hello() {
- return "helloworld2";
- }
- }
12. 启动项目
13. 访问项目 (低版本可能无法访问, 2 版本可用)
http://localhost:8012/hello2
方法三
访问 http://start.spring.io/
点击 Generate Project 下载项目压缩包
解压后, 使用 eclipse,Import -> Existing Maven Projects -> Next -> 选择解压后的文件夹 -> Finsh,OK done!
来源: http://www.bubuko.com/infodetail-2946263.html