zoukankan      html  css  js  c++  java
  • 构建SpringBoot项目

    1.选择创建方式

     2.项目名

     3.选择项目依赖

     

     4. 添加webapp目录

     点击跳转查看

    添加web依赖(选web依赖后会自动添加,不用再添加)

       <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>

    application.properties文件配置

    注意端口不能冲突

    #配置端口号  项目名
    server.port=8080
    server.servlet.context-path=/springbootdemo

    写个测试的controller

    /**
     * @(#)WebTest.java, 2020/7/27.
     * <p/>
     * Copyright 2020 Netease, Inc. All rights reserved.
     * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
     */
    package com.lhh.springbootdemo.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import org.springframework.web.bind.annotation.RestController;
    
    
    /**
     * @author lvhouhou(lvhouhou @ 163.com)
     */
    @RestController
    public class WebTest {
    
    
        @RequestMapping("hello")
        public String getHello(){
            return "Hello";
        }
    }

    启动项目

    浏览器访问  

    OK   

  • 相关阅读:
    Linux软件管理
    Linux计划任务与进程管理
    PHP学习 Day_04
    Linux网络管理
    单播组播的实现
    Linux 下的tmpfs文件系统(/dev/shm)
    11.Linux date命令的用法
    Luogu P3783 [SDOI2017]天才黑客
    Luogu P3768 简单的数学题
    Luogu P2336 [SCOI2012]喵星球上的点名
  • 原文地址:https://www.cnblogs.com/lvhouhou/p/13388211.html
Copyright © 2011-2022 走看看