springboot 框架搭建(快速入门)

1导入依赖

  <!--spring工程需要继承的父工程-->
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.0</version>
  </parent>

  <dependencies>
    <!--web开发需要的起步依赖-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
  </dependencies>

 

2写springboot启动类

package com.jc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


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

}

 

3直接执行main方法

注意启动类位置>其他

springboot 内部整合了spring 、springmvc等繁琐的配置文件  

优点少配置

 

4springboot的配置文件

application.properties

  application.yaml/yml  ----键值对形式的 key:空格 value

   

 

posted on 2022-02-02 23:19  ziwang520  阅读(336)  评论(0编辑  收藏  举报