zoukankan      html  css  js  c++  java
  • 入门案例(hello-springBoot)

    入门案例(hello-springBoot)

    系统要求

    Java 8+

    Maven 3.6.6+

    创建Maven项目工程

    引入 pom.xml 依赖
        <!--1.导入父工程-->
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.5.0</version>
        </parent>
    
        <!--2.导入springBoot的Web场景-->
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
            </dependency>
        </dependencies>
    
    创建主程序 MainApplication 类
    package com.xiang;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    /**
     * Created by IntelliJ IDEA.
     * User: xiang
     * Date: 2021/10/12 10:10
     */
    @SpringBootApplication
    public class MainApplication {
        public static void main(String[] args) {
            SpringApplication.run(MainApplication.class, args);
        }
    }
    
    
    编写业务 HomeController 类
    package com.xiang.controller;
    
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    /**
     * Created by IntelliJ IDEA.
     * User: xiang
     * Date: 2021/10/12 10:11
     */
    @RestController
    public class HomeController {
        @RequestMapping("/hello")
        public String Hello() {
    //        return "Hello SpringBoot";
            return "<h1 style='color:red'>Hello SpringBoot<h1>";
        }
    }
    
    
    运行

  • 相关阅读:
    Spring 核心API
    python装饰器
    python作业(day1)
    Kali Linux 更新源
    一维数组模拟数据结构-------栈
    Spring事务管理
    Linux用户管理命令
    Linux 帮助命令
    Spring对jdbc的支持
    springboot集成shiro 循环重定向
  • 原文地址:https://www.cnblogs.com/d534/p/15397346.html
Copyright © 2011-2022 走看看