Java EE-Entwicklung existiert: verschiedene Konfigurationen, komplexe Bereitstellung und Integration von Bibliotheken von Drittanbietern ist nicht einfach
Die oben genannten Schmerzpunkte existieren, also wurde springboot geboren. Es hat viele eingebaute gemeinsame Konfigurationen, die die JavaEE-Entwicklung einfacher machen
Und das Projekt kann ohne zusätzliche Abhängigkeiten vom Webcontainer unabhängig ausgeführt werden
1. pom.xml-Konfiguration
<!--继承父项目,里面有各种库的版本号 版本依赖--> <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. Programmeingabe
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. Controller-Klasse testen
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. Ingenieurstruktur:
Das Obige ist die Einführung in die Grundlagen von Springboot, ich wünsche Ihnen eine gute Zeit!