zoukankan      html  css  js  c++  java
  • Spring Boot 入门

    一、Spring Boot 入门

    环境约束

    –jdk1.8:Spring Boot 推荐jdk1.7及以上;java version "1.8.0_112"

    –maven4.x:maven 3.3以上版本;Apache Maven 3.3.9

    –IntelliJIDEA2017:IntelliJ IDEA 2017.2.2 x64、STS

    统一环境;

    编写第一HelloWorld程序

     SpringBoot的主程序:

    package com.example.demo;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    @SpringBootApplication
    public class DemoApplication {

    public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
    }
    }
    SpringBoot的Controller的程序:
    package com.example.demo.controller;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;

    @ResponseBody
    @Controller
    public class HelloWolrd {
    @RequestMapping("/hello")
    public String hello(){
    return "hello";
    }
    }

    这样我们就可以运行程序了,程序跑起来之后在浏览器中输入LocalHost:8080/hello就可以进行访问了
    下图就是成功后的样子

     

    我的时候要注意一下文件的位置,你建立的Controller只能在DemoApplication 也就是SpringBoot的主程序同一层级或者下一层级,只有这样能执行。

  • 相关阅读:
    ES6新语法之---块作用域let/const(2)
    sass变量
    Ruby(或cmd中)输入命令行编译sass
    sass的安装
    鼠标滚动兼容
    HTML5新标签兼容——> <!--<if lt IE 9><!endif-->
    #include stdio.h(7)
    #include stdio.h(6)
    #include stdio.h(5)
    #include stdio.h(3)
  • 原文地址:https://www.cnblogs.com/xyzmy/p/9769119.html
Copyright © 2011-2022 走看看