如今項目裏使用springboot,平時開發並不太關注springboot的一些基本配置,如今想整理一下springboot相關內容。spring
實際開發中都會由於各類業務需求在springboot上添加不少東西,這裏想先來看一個最簡單最基本的springboot。apache
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.1.9.RELEASE</version> </dependency>
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.love.main.Applicaiton</mainClass> </configuration> </plugin>
這裏 mainClass 配置的是springboot程序的啓動入口類springboot
附上完整pom.xml:maven
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com</groupId> <artifactId>love</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>love</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.1.9.RELEASE</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.love.main.Applicaiton</mainClass> </configuration> </plugin> </plugins> </build> </project>
附上完整代碼:spring-boot
package com.love.main; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * spring boot 運行入口 * @author Mars * */ @SpringBootApplication public class Applicaiton { public static void main(String[] args) { SpringApplication.run(Applicaiton.class, args); } }
能夠看出springboot的入口代碼很是簡單,是經過最基本的 main() 方法開始執行的。ui
這裏須要添加上 @SpringBootApplication 註解。url
這樣一個最基本最簡單的springboot程序就跑成功了。spa
後續會進行更多springboot內容整理。插件