zoukankan      html  css  js  c++  java
  • 一分钟搭建Spring Boot

    1.首先你的电脑需要安装jdk、Apache Maven、Intellij IDEA

    2.新建项目  (敲重点,有的同学有没有Spring Initializr 这个请到本文章后面看安装步骤

    3.选择基本条件

     

    添加HelloCtrl类

    添加如下代码

    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller//这是一个控制器
    public class HelloCtrl
    {
        @RequestMapping("/")//将地址映射到 / 即访问http://localhost:8080 就可以进入这个方法
        @ResponseBody//返回数据,如果不添加该注解将在resources/templates下寻找与之对应的html模版
        public String hello()
        {
            return "hello spring boot";
        }
    }

    4.测试程序

    打开浏览器,http://localhost:8080

    出现hello spring boot字样则成功

     --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    没有Spring Initializr

    1.【file】->【Settings】->【Plugins】

  • 相关阅读:
    JVM类加载(3)—初始化
    JVM类加载(1)—加载
    SQL笔记
    html5离线Web应用
    推荐3个很好的html5 网址
    HTML 5 File API应用实例
    异常与错误的区别
    html5Local Storage(本地存储)
    HTML5 js api 新的选择器
    5个HTML5 API
  • 原文地址:https://www.cnblogs.com/PerZhu/p/10708809.html
Copyright © 2011-2022 走看看