0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WindowsPCにJava17+STS+Mavenの環境を構築する

Posted at

WindowsPCにJava17+STS+Mavenの環境を構築する

環境情報

  • windows10 Enterprise
  • JDK 17
  • STS 4.21.0
  • Maven 3.8.5

流れ

  1. 環境構築
    1. JDK インストール
    2. Maven インストール
    3. STS インストール
  2. HelloWorld 表示
    1. 新規 SpringBoot プロジェクト作成
    2. Controller クラス作成
    3. デバッグ実行
    4. Hello World 表示

環境構築手順

  1. JDK インストール
    以下のサイトを参考にインストールする。
    OpenJDK 17 のインストールと設定(Windows 上)
  2. Maven インストール
    以下のサイトを参考にインストールする。
    Apache Maven のインストール手順(Windows 向け)
  3. STS インストール
    以下のサイトでインストーラをダウンロードする。
    Spring Tool 4
    ダウンロードしたjar ファイルを解凍する。インストールはこれで終わり。
    解凍した「sts-4.x.x.RELEASE」フォルダを選択すると、「SpringToolSuite4.exe」があるので、このファイルを実行すると、STS が起動する。
  4. STS 日本語化
    1. 以下のサイトでインストーラをダウンロードする。
      Pleiades プラグイン・ダウンロード
    2. zipファイルを解凍し、setup.exe を実行する。
    3. 日本語化するアプリケーションで「SpringToolSuite4.exe」を選択し、「日本語化する」を押す。
    4. STS を再度起動し、日本語になってることを確認する。

HelloWorld 表示手順

  1. 新規 SpringBoot プロジェクト作成
    新規Springスターター・プロジェクトの作成をクリック。
    2024-01-03-19-00-42.png
    タイプをMavenにして、他はデフォルト。
    2024-01-03-19-01-14.png
    簡単な RestAPI を作るだけなので、以下の依存関係だけ。
    2024-01-03-19-02-48.png
    ここも特に変更せず。
    2024-01-03-19-03-27.png

  2. Controller クラス作成
    新しくHelloWorldController.javaを作成し、コード入力。
    2024-01-03-19-12-02.png

    package com.example.demo.helloWorld;
    
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class HelloWorldController {
    
        @RequestMapping("/helloWorld")
        public String home() {
            return "Hello World!";
        }
    
    }
    
  3. デバッグ実行
    プロジェクトを右クリック>デバッグ>Spring Boot アプリケーションでデバッグ実行
    2024-01-03-19-12-47.png
    コンソールに以下が表示される。
    2024-01-03-19-13-35.png

  4. Hello World 表示
    ブラウザ立ち上げて以下にアクセス。
    http://localhost:8080/helloWorld
    2024-01-03-19-14-34.png

終わり

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?