首页 > 编程语言 > 详细

SpringBoot helloworld

时间:2018-06-26 00:22:35      阅读:300      评论:0      收藏:0      [点我收藏+]

1. 构建工程

a. 地址:http://start.spring.io/

b. 填写Group、Artifact

c. 生成工程、下载、解压

2. 项目结构

技术分享图片

3. 添加controller内容

package com.jihite.helloworld.controller;

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

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String index() {
        return "Hello World~";
    }
}

4. pom.xml

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
</dependencies>

5. 运行main函数

请求:http://localhost:8080/hello

返回:Hello World~

 

SpringBoot helloworld

原文:https://www.cnblogs.com/kaituorensheng/p/9226717.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!