zoukankan      html  css  js  c++  java
  • 一、Hello Spring Boot

    package com.ld.controller;
    
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class IndexController {
    
        @RequestMapping(value = "index")
        public String index() {
    
            return "Hello World!!!";
        }
        @RequestMapping(value = "show")
        public String show(){
            return "Hello Spring Boot";
        }
    }
    package com.ld.controller;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class RootApplication {
    
        public static void main(String [] args) {
            SpringApplication.run(RootApplication.class, args);
        }
    }

    pom.xml文件配置

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.4.0.RELEASE</version>
            <relativePath /> <!-- lookup parent from repository -->
    </parent>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>

    clipboard

    运行程序main方法,在浏览器输入:http://localhost:8080/index

    clipboard

    clipboard

  • 相关阅读:
    POJ3678 KATU PUZZLE
    poj3321(codevs1228)苹果树
    codevs 1955 光纤通信 USACO
    codevs 1027 姓名与ID
    codevs 1051 接龙游戏
    洛谷 P1717 钓鱼
    codevs 1062 路由选择
    洛谷 P1083 借教室
    codevs 2596 售货员的难题
    Vijos 1053 easy sssp
  • 原文地址:https://www.cnblogs.com/xxt19970908/p/6685806.html
Copyright © 2011-2022 走看看