0
1

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 3 years have passed since last update.

IntelliJとSpring bootでHello Worldしよう

Last updated at Posted at 2020-06-07

IntelliJとは

IntelliJ IDEA (インテリジェイ アイディア) は、チェコに本社を置くJetBrains社が開発した、Javaなど数多くのプログラミング言語に対応した統合開発環境である。

https://www.jetbrains.com/ja-jp/idea/
https://ja.wikipedia.org/wiki/IntelliJ_IDEA

IntelliJのダウンロード

プロジェクト作成

Spring Initializrでプロジェクトのひな型を作成します。

各種設定は初期設定のまま、DependenciesにてSpring Webを選択します。
image.png

「Generate」ボタンをクリックします。

zipファイルがダウンロードされるので解凍してください。
image.png

Projectのインポート

解凍したdemoフォルダにあるpom.xmlを右クリックします。
「プログラムから開く」->「別のプログラムを選択」->IntelliJを選択します。

IntelliJは自動的にdemoプロジェクトを開きます。

下記のDemoApplicatoin.javaを開きます。
image.png

Demo用Javaファイルを編集

demoApplication.javaのファイルを編集します。

DemoApplicatoin.java
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class DemoApplication {

	@RequestMapping("/helloworld")
	String index(){
		return "Hello World!";
	}

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

}

src配下のdemoApplication.javaを右クリックします。
Run DemoApplication mainを選択します。
実行が完了まで待ちます。

デモサイトへアクセスします。

http://localhost:8080/helloworld にアクセスすると、下記の画面が表示されます。
image.png

次回

IntelliJで簡単なREST APIを作ります。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?