黄山市网站建设_网站建设公司_Oracle_seo优化
2026/1/14 20:04:57 网站建设 项目流程

一:搭建一个SpringBoot项目

1:项目搭建

1:创建一个空项目

2:创建一个Maven模块

3:添加Parent标签

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.0.5</version> </parent>

4:添加Web场景依赖

场景启动器:

<dependencies> <!--web开发场景启动器--> <!--json/tomcat/web/webmvc都引入进来了--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>

5:添加主程序

package com.dashu; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * SpringBoot项目入口主程序 * 标注这是一个SpringBoot应用 */ @SpringBootApplication public class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class,args); } }

6:编写一个Rest请求

package com.dashu.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @GetMapping("/test/springboot") public String test(){ return "hello springboot"; } }

7:打包

<build> <plugins><plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin></plugins> </build>

mvn clean package 把项目打成可执行的jar包。【fat包】

2:特性总结

简化整合

导入相关场景,就存在先关功能

官方提供的场景:spring-boot-starter-xxx

第三方提供的场景:x-spring-boot-starter

场景一导入完事都具备。

简化开发

无序写任何配置,直接写因为即可
但是如果就是想修改配置,那么就需要引入一个applycation.properties

例如修改启动端口

SpringBoot官方提供的starter

spring-boot-starter-ws,

spring-boot-starter-websocket,

spring-boot-starter-web,

spring-boot-starter-velocity,

spring-boot-starter-validation,

spring-boot-starter-undertow,

spring-boot-starter-tomcat,

spring-boot-starter-thymeleaf,

spring-boot-starter-test,

spring-boot-starter-social-twitter,

spring-boot-starter-social-linkedin,

spring-boot-starter-social-facebook,

spring-boot-starter-security,

spring-boot-starter-remote-shell,

spring-boot-starter-redis,

spring-boot-starter-mustache,

spring-boot-starter-mobile,

spring-boot-starter-mail,

spring-boot-starter-logging,

spring-boot-starter-log4j2,

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询