网站的建设步骤包括,广州手机网站建设多少钱,招聘小程序怎么制作,电子商务网站建设 概念说明
本文建立一个最基本的SpringBoot3项目#xff0c;依赖项仅包含 spring-web#xff08;SpringMVC#xff09;。
备注#xff1a;SpringBoot3需要JDK17支持#xff0c;配置方法参考#xff1a; SpringBoot3项目中配置JDK17
项目结构图示 POM
?xml version依赖项仅包含 spring-webSpringMVC。
备注SpringBoot3需要JDK17支持配置方法参考 SpringBoot3项目中配置JDK17
项目结构图示 POM
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.1.3/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.example/groupIdartifactIdhello-spring-boot3/artifactIdversion1.0/versionnameHelloSpringBoot3/namedescriptionDemo project for Spring Boot3/descriptionpropertiesjava.version17/java.version/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependenciesdependencyManagementdependenciesdependencygroupIdorg.yaml/groupIdartifactIdsnakeyaml/artifactIdversion2.0/version/dependency/dependencies/dependencyManagementbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/project
启动器Application
package com.example;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication
public class HelloSpringBoot3Application {public static void main(String[] args) {SpringApplication.run(HelloSpringBoot3Application.class, args);}}
配置文件yml
使用的默认配置未添加任何内容。
控制器Controller
package com.example.web.controller;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;RestController
RequestMapping(test)
public class TestController {GetMapping(hello)public String hello() {return Hello SpringBoot3;}}
接口调用示例