1. 程式人生 > >Spring Boot 使用IntelliJ IDEA創建一個web開發實例(二)

Spring Boot 使用IntelliJ IDEA創建一個web開發實例(二)

reat TP idea debug str mage 地址 eat ica

1. 創建一個Controller類

package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2018-06-09.
 */
@RestController
public class DemoController {

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

2. 啟動應用,右鍵選中DemoApplication.java,在彈出菜單中選擇run或debug

技術分享圖片

技術分享圖片

3. 輸入訪問地址 http://localhost:8080/hello

技術分享圖片

Spring Boot 使用IntelliJ IDEA創建一個web開發實例(二)