Eclipse創建springboot項目的方式

安裝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!

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章