zoukankan      html  css  js  c++  java
  • spring boot-2.Hello world

    由于 个人习惯,我选择使用STS来作为开发工具。跳过手动构建spring boot 项目的环节,直接使用向导创建spring boot 项目。

    1.创建spring boot项目

    File ---->New--->Spring Starter Project

    填写好项目名称项目坐标,点击Finish即可。项目的路径如下图所示:

    右击项目名称,run as --->spring boot app 即可运行项目。

    然后我们新建controller 包,新建helloworldcontroller.java 

    在helloworldcontroller.java 中编写代码

    package com.springboot.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    public class helloworldcontroller {
        
        @ResponseBody
        @RequestMapping("/hello")
        public String helloworld() {
            return "Hello World";
        }
    }

    重启服务,在浏览器中请求hello,即可得到如下界面

    至此,一个简单的spring boot 应用就快速搭建完成。接下来我们来结合文档深入查看其中的原理。

  • 相关阅读:
    Go语言专题
    计算机网络专题
    分布式系统理论专题
    Scala语言专题
    Zookeeper专题
    Java虚拟机专题
    Java并发编程专题
    git使用指南
    Oracle查询今天、昨天、本周、上周、本月、上月数据
    python3 装饰器
  • 原文地址:https://www.cnblogs.com/li-zhi-long/p/9455596.html
Copyright © 2011-2022 走看看