SpringBoot入门初体验

概述

  Java项目开发中繁多的配置,复杂的部署流程和第三方技术集成让码农在开发项目中效率低下,因此springBoot应运而生。

 环境

IntelliJ IDEA 2018.3

jkd1.8

开始(傻瓜操作,记得在有网环境安装)

初次运行得等待maven安装完成(时间根据你网速而定),然后看下目录结构

运行

浏览器查看

写第一个接口,创建一个DemoController类

package com.xmlxy.firstspringbootproject;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/*测试类 2019-7-26*/
@RestController
public class DemoController
{
    @RequestMapping(value = "/demo",method = RequestMethod.GET)
    public String demo()
    {
        return "Hello SpringBoot";
    }
}

运行,浏览器访问  http://127.0.0.1:8080/demo

总结

从springBoot项目的创建到运行,我们会发现前后不过10分钟左右(maven初次运行),一个简单的web项目就运行起来,没有了繁琐的tomcat配置(内置servlet容器),maven配置简化等。

原文地址:https://www.cnblogs.com/dslx/p/11249924.html