• springBoot基本配置


    Spring Boot 基本配置

    1、新建maven jar工程 使用依赖

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.pinyougou</groupId>
    
    <artifactId>springbootdemo-helloworld</artifactId>
    
    <version>0.0.1-SNAPSHOT</version>
    
    <!--spring boot 项目必须继承spring boot 父工程 -->
    
    <parent>
    
    <artifactId>spring-boot-starter-parent</artifactId>
    
    <groupId>org.springframework.boot</groupId>
    
    <version>1.5.6.RELEASE</version>
    
    </parent>
    
    <dependencies>
    
    <!--使用spring boot 开发web项目的基础依赖 -->
    
    <dependency>
    
    <groupId>org.springframework.boot</groupId>
    
    <artifactId>spring-boot-starter-web</artifactId>
    
    </dependency>
    
    </dependencies>
    
    </project>

    2、新建启动类

    package com.springboot;
    
     
    
    import org.springframework.boot.SpringApplication;
    
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
     
    
    @SpringBootApplication
    
    public class Application {
    
     
    
    public static void main(String[] args) {
    
    SpringApplication.run(Application.class, args);
    
    }
    
    }

    3、启动效果

     

    4、访问

     

    5、添加controller

    package com.springboot.controller;
    
     
    
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import org.springframework.web.bind.annotation.RestController;
    
     
    
    @RestController
    
    public class HelloController {
    
     
    
    @RequestMapping("/hello")
    
    public String hello() {
    
    return "spring boot is so easy to learn!";
    
    }
    
    }

    6、重新启动

     

    7、访问

      

  • 相关阅读:
    DOM 与BOM
    尝试json文件导入数据
    js事件监听简介
    js事件简介
    js中的for语句简介
    作业练习正则表达式
    简单总结-BOM
    web前端第三次作业em,fr,rem,px简单解释及颜色表
    web第二次作业练习grid
    web前端课程第一次作业----注册页面代码(2018-9-14)
  • 原文地址:https://www.cnblogs.com/alexzhang92/p/10405493.html
Copyright © 2020-2023  润新知