Java EE development exists: various configurations, complex deployment, and integration of third-party libraries is not easy
The above pain points exist, so springboot was born. It has many built-in common configurations, making JavaEE development easier
And the project can run independently without additional dependencies on the web container
1. pom.xml configuration
<!--继承父项目,里面有各种库的版本号 版本依赖--> <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>
2. Program entry
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); } }
3. Test controller class
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"; } }
4. Engineering structure:
The above is the introduction to the basics of springboot, I wish you a good time!