美文网首页
springboot基础(二)

springboot基础(二)

作者: 晚风吹___ | 来源:发表于2020-04-13 22:42 被阅读0次

    一、创建项目

    选择Spring Initalizr

    image

    配置maven相关和主包名

    image

    选择项目初始化依赖

    image

    工程目录

    image

    二、基本流程

    1、XXXApplication

    程序的入口

    @SpringBootApplication
    public class FirstspringbootApplication {
        public static void main(String[] args) {
            SpringApplication.run(FirstspringbootApplication.class, args);
        }
    }
    

    2、resources/application.properties

    默认application.properties也可以是application.yml是程序的配置文件。默认为空

    在Springboot中,推荐使用properties或者YAML文件来完成配置,但是对于较复杂的数据结构来说,YAML又远远优于properties

    # 修改端口
    server.port=8000
    # 请求前缀
    server.servlet.context-path=/api
    

    3、在创建HelloController

    @RestController
    public class HelloController {
        @GetMapping("/")
        public String hello(String msg) {
            return msg;
        }
    }
    

    相关文章

      网友评论

          本文标题:springboot基础(二)

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