springboot2之系统架构基础(一)项目创建

以idea工具讲解

step1:创建一个springboot项目

idea中不像eclipse,没有项目的概念,这里创建一个module

springboot2之系统架构基础(一)项目创建_第1张图片

step2

springboot2之系统架构基础(一)项目创建_第2张图片

step3

springboot2之系统架构基础(一)项目创建_第3张图片

step4.

目前我们只需要勾选上WEB依赖即可,后面依赖需要时一一添加

springboot2之系统架构基础(一)项目创建_第4张图片

step5

springboot2之系统架构基础(一)项目创建_第5张图片

step6

创建控制器

springboot2之系统架构基础(一)项目创建_第6张图片

package com.hg.java.demo.business.test;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: hg
 * @Date: 2018/12/10 11:52
 * @Version 1.0
 */
@RestController
@RequestMapping("/testController")
public class TestController {

    @GetMapping("/show/{name}")
    public String show(@PathVariable String name){
        return "hi, " +name +" , 你好!";
    }

}

访问路径:http://localhost:8080/testController/show/zhangsan

注意:这样发布是没有项目名称的。若需要项目名称,在resource目录下,创建application.yml配置文件,添加以下配置

server:
  servlet:
    context-path: /demo

配置后访问路径:http://localhost:8080/demo/testController/show/zhangsan

step7

项目结构

springboot2之系统架构基础(一)项目创建_第7张图片

 

你可能感兴趣的:(springboot,整合系列)