SpringBoot是由Pivotal团队提供的全新框架,可以帮助我们开发基于Spring的、独立的、生产级的应用程序。
其中SpringBoot的官网是:Spring Boot Reference Documentation
SpringBoot的主要目标是:
注意:SpringBoot 并不是Spring功能上的增强,而是提供了一种快速使用Spring的方式。
这里先采用的是手动创建的方式
新建Maven项目
引入依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
创建引导类
package com.north;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @Author North
* @Date 2024/5/2
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
开发控制器类
package com.north.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author North
* @Date 2024/5/2
*/
@RestController
@RequestMapping("/books")
public class BookController {
@RequestMapping("/save")
public String save() {
System.out.println("user save");
return "hello springboot!";
}
}
运行自动生成的Application类
官网地址
实际开发
pom中starter、parent作用是什么?