zoukankan      html  css  js  c++  java
  • SpringBoot2 helloWorld

    新建Maven 然后我们导入web 的 GAV 和 SpringBoot 的 parent  最后我们测试:

    <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>
    package com.xianyu.Test;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class MainApplication {
        public static void main(String[] args) {
            SpringApplication.run(MainApplication.class,args);
        }
    }
    启动类Application
    package com.xianyu.Test.Controller;
    
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController //Controller + ResponseBody     之前说过的
    public class HelloController {
    
        @RequestMapping("/hello")
        public String testMapper1(){
            return "你好!世界!";
        }
    
    }
    Controller 控制器

    运行:

    打jar包还是老样子  直接插件 然后打包即可【先清除下】

    插件就是:

    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>

    本文来自博客园,作者:咸瑜,转载请注明原文链接:https://www.cnblogs.com/bi-hu/p/15225230.html

  • 相关阅读:
    vue 给嵌套的iframe子页面传数据 postMessage
    左边宽度固定,右边宽度自适应的三种写法
    全局变量声明的规范化
    利用__index和__newindex实现默认值表、监控表、只读表
    Metatable和Metamethod
    Lua中的协同程序 coroutine
    Lua中的require
    Lua基础
    D3D的绘制
    效率相关笔记
  • 原文地址:https://www.cnblogs.com/bi-hu/p/15225230.html
Copyright © 2011-2022 走看看