zoukankan      html  css  js  c++  java
  • SpringBoot2-01

    Spring Boot2入门

    1.使用idea新建一个名为boot的Maven工程。
    2.点击右下角的“Enable Auto-Import”选项,idea将会自动下载相关的依赖包。

    3.点击boot目录下的pom.xml文件,引入以下依赖:

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.3.4.RELEASE</version>
        </parent>
    
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
        </dependencies>
    

    4.手动创建主程序类,类名默认为MainApplication。

    package com.per.boot;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    /**
     *使用 @SpringBootApplication修饰该类表示这是一个SpringBoot应用
     */
    @SpringBootApplication
    public class MainApplication {
        public static void main(String[] args) {
            SpringApplication.run(MainApplication.class,args);
        }
    }
    

    5.编写业务

    package com.per.boot.Controller;
    
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class HelloWorld {
    
        @RequestMapping("/hello")
        public String handle(){
            return "Hello, Spring Boot2!";
        }
    }
    

    6.测试:直接运行main方法

  • 相关阅读:
    从马琳决赛被翻盘想到的
    C语言中的位运算
    瑞星杀毒软件所有监控已禁用!
    回来了,重新开始
    使用 javascript 标记高亮关键词
    我的webgis客户端引擎AIMap
    RPM 命令大全
    终结IE6下背景图片闪烁问题
    linux下挂载硬盘光驱和U盘
    在JavaScript中实现命名空间
  • 原文地址:https://www.cnblogs.com/daydayupup/p/14423956.html
Copyright © 2011-2022 走看看