美文网首页Spring-Boot
Spring boot 初识(一)

Spring boot 初识(一)

作者: grey_sky | 来源:发表于2017-04-06 09:26 被阅读0次

    创建Spring boot项目

    1.打开http://start.spring.io spring boot 官网,选择一些配置项,点击Generate Project 导出spring boot的项目包。


    2.解压下载好的压缩包,用eclipse 导入maven 项目,等待项目初始化,Spring boot 初始化完成后目录结构会变成这样。

    3.这样Spring boot就算初始化完成了,从 SpringbootApplication 就可以启动这个项目。

    构建web模块

    1.查看xml配置,Spring boot 默认有两个模块:
    <pre>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    </dependency>
    </pre>
    核心模块跟 test模块
    现在添加web模块,添加了spring相关的一些模块,包括tomcat
    <pre>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    </pre>
    2.测试一下web模块:
    <pre>
    @RestController
    public class TestController {
    @RequestMapping("/test")
    public String test(){
    return "test";
    }
    </pre>
    运行SpringbootApplication 会启动内置tomcat,端口号为默认的8080,
    在浏览器输入http://localhost:8080/test

    3.github地址: https://github.com/sunzhonghui/springboot

    相关文章

      网友评论

        本文标题:Spring boot 初识(一)

        本文链接:https://www.haomeiwen.com/subject/bzbxattx.html