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

以idea工具讲解

step1:创建一个springboot项目

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

step2

step3

step4.

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

step5

step6

创建控制器

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

项目结构

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值