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

Spring Boot 使用IntelliJ IDEA创建一个web开发实例(二)

Spring Boot 使用IntelliJ IDEA创建一个web开发实例(二)

3. 输入访问地址 http://localhost:8080/hello

Spring Boot 使用IntelliJ IDEA创建一个web开发实例(二)

 

相关文章:

  • 2021-07-25
  • 2021-12-04
  • 2021-07-13
  • 2021-10-07
  • 2021-07-13
  • 2021-06-12
  • 2021-06-08
  • 2021-12-21
猜你喜欢
  • 2021-05-28
  • 2021-07-02
  • 2022-03-01
  • 2021-12-10
  • 2021-05-17
  • 2021-12-04
  • 2021-06-13
相关资源
相似解决方案