Java EE开发存在:配置繁多、部署复杂、集成第三方库并不简单
存在以上痛点,所以springboot诞生了,它内置很多常用配置,让JavaEE开发更加简单
并且项目可以独立运行,无需额外依赖web容器
一、pom.xml配置
<!--继承父项目,里面有各种库的版本号 版本依赖--> <parent> <artifactId>spring-boot-starter-parent</artifactId> <groupId>org.springframework.boot</groupId> <version>2.3.4.RELEASE</version> </parent> <!--依赖--> <dependencies> <!--Web项目依赖,已经集成了SpringMVC中很多的常用库--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--热部署,重新编译之后立刻生效 main方法会运行两次 debug模式下使用--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> </dependencies> <!--插件,打包--> <build> <finalName>springboot01</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.3.0.RELEASE</version> </plugin> </plugins> </build>
二、程序入口
package com.mj; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class,args); } }
三、测试控制器类
package com.mj.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @GetMapping("/test") public String test() { return "SpringBoot run success111"; } }
四、工程结构:
以上就是springboot基础入门,祝玩得愉快!