LoginSignup
0

More than 3 years have passed since last update.

Spring + Gradle + Javaクイックスタート

Posted at

1. 雛形の入手

ここから、以下の設定で、雛形をダウンロード。

Project: Gradle Project
Language: Java
Spring Boot: 2.1.4
Dependencies: Web

スクリーンショット 2019-04-23 14.06.49.png

2. プログラムを書く

HelloController.javaを作成。

HelloController.java
package com.example.demo;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("hello")
public class HelloController {

    @GetMapping("")
    public String index(Model model) {
        return "Hello!!";
    }
}

3. 実行

DemoApplication.javaの緑の三角をクリックして実行。
スクリーンショット 2019-04-23 14.12.12.png

http://localhost:8080/hello にアクセス。
スクリーンショット 2019-04-23 14.09.59.png

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