LoginSignup
1
2

More than 3 years have passed since last update.

Eclipse - Springboot

Last updated at Posted at 2019-10-22

環境

  • Elipcse 2018-09(4.9) ※Pleiades All in oneを使用
  • Java 8

EclipseにSTSを入れる

Spring Tools 4をインストール

  • EclipseマーケットでSTS4を探してインストールを押す
    image.png
  • 確認を押す
    image.png
  • 「使用条件の条項に同意します」を選択して完了を押す
    image.png
  • 今すぐ再起動を押してEclipseを再起動する
    image.png

Eclipseのパースペクティブを表示する

  • メニュから「ウインドウ→パースペクティブ→パースペクティブを開く→その他」を選択する
    image.png
  • Springを選択して開くを押す
    image.png
  • パースペクティブのSpringを選択する
    image.png

プロジェクト作成

  • メニュー「ファイル→新規作成→Springスタータープロジェクト」を選択する
  • 次へを押す
    image.png
  • 依存関係を追加指定し完了を押す
    image.png
  • 依存関係のインポートを待つ
    image.png
  • pom.xmlの1行目で不明なエラーが出たらmaven pluginのバージョン指定を追加する
pom.xml
    <properties>
            <java.version>1.8</java.version> 
            <!-- 下の1行を追加する -->  
            <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
    </properties>

動作確認

Controllerを作成する

HelloController.java

package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HelloContoller {

    @RequestMapping("/")
    public String hello() {
        return "hello";
    }
}

HTMLを作成する

hello.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Spring demo</title>
</head>
<body>
  <h1>Hello</h1>
</body>
</html>

ツールバー実行から「実行→Spring bootアプリケーション」を選択して「http://localhost:8080」にアクセスする

image.png

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2