网站之家查询域名,新网站如何被快速收录,平台推广话术,南昌网站建设联系方式目录
SpringBoot是由Pivotal团队提供的全新框架#xff0c; 其设计目的是用来简化Spring应用的初始搭建以及开发过程。
1.创建入门工程案例
①创建新模块#xff0c;选择Spring初始化#xff0c;并配置模块相关基础信息 ②开发控制器类
controller/BookController.jav…目录
SpringBoot是由Pivotal团队提供的全新框架 其设计目的是用来简化Spring应用的初始搭建以及开发过程。
1.创建入门工程案例
①创建新模块选择Spring初始化并配置模块相关基础信息 ②开发控制器类
controller/BookController.java
package com.example.controller;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;RestController
RequestMapping(/books)
public class BookController {GetMapping(/{id})public String getById(PathVariable Integer id) {System.out.println(id id);return hello, spring boot!;}
}
③运行自动生成的Application类 2.Spring和SpringBoot程序对比 看一下SpringBoot项目的pom.xml spring-boot-starter-web依赖定义了当前项目所使用的所有项目目标以达到减少依赖配置的目的。
spring-boot-starter-parent所有SpringBoot项目要继承的项目定义了若干个坐标版本号。依赖管理而非依赖
SpringBoot的引导类是项目的入口运行main方法就可以启动项目。 SpringBoot项目内置Tomcat服务器。如何变更依赖项比如换个jetty服务器。
pom.xml可能因为版本问题需要配置一下jakarta-servlet.version5.0.0/jakarta-servlet.version
propertiesjava.version20/java.versionjakarta-servlet.version5.0.0/jakarta-servlet.version
/properties
dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdexclusionsexclusiongroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-tomcat/artifactId/exclusion/exclusions/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-jetty/artifactId/dependency
/dependencies3.从SpringBoot官网创建工程
Spring Boot 4.SpringBoot项目快速启动
使用JAR包方便前端用户快速启动后台项目。 具体操作
执行指令
java -jar springboot_demo-0.0.1-SNAPSHOT.jar