zoukankan      html  css  js  c++  java
  • Spring Boot快速建立HelloWorld项目

    Spring Boot使我们更容易去创建基于Spring的独立和产品级的可以”即时运行“的应用和服务。支持约定大于配置,目的是尽可能快地构建和运行Spring应用。

    构建环境

    JDK 6+

    Maven

    创建项目

    1.使用Maven创建一个普通Maven应用即可。

    2.修改pom.xml文件

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

    3.创建java文件SampleController.java

    package hello;

    import org.springframework.boot.*;
    import org.springframework.boot.autoconfigure.*;
    import org.springframework.stereotype.*;
    import org.springframework.web.bind.annotation.*;

    @Controller
    @EnableAutoConfiguration
    public class SampleController {

        @RequestMapping("/")
        @ResponseBody
        String home() {
            return "Hello World!";
        }

        public static void main(String[] args) throws Exception {
            SpringApplication.run(SampleController.class, args);
        }
    }

    4.Run As Java Application

  • 相关阅读:
    Codeforces 1381B Unmerge(序列划分+背包)
    daily overview(2020.03.07update:该网站打不开惹
    矩阵相关
    颓式子
    51nod 1603 限高二叉排列树/1412 AVL树的种类
    模板合集(未完
    【luogu5651】 基础最短路练习题 [?]
    一个大Za
    【2019.11.11】
    【noip2017】
  • 原文地址:https://www.cnblogs.com/qingyuuu/p/5910044.html
Copyright © 2011-2022 走看看