Spring Boot啓動器(Spring Boot Starters)
處理各類庫的依賴管理對於大型項目來說是一項艱鉅的任務,Spring Boot通過提供一組依賴項來解決此問題,以方便開發人員。
例如,如果要使用Spring和JPA進行數據庫訪問,則在項目中包含spring-boot-starter-data-jpa依賴項就夠了。
所有Spring Boot啓動器都遵循相同的命名模式spring-boot-starter- ,其中表示它是應用程序的一種類型。
例子
請看下面的Spring Boot啓動器,以便更好地理解 -
Spring Boot Starter Actuator
此依賴項用於監視和管理您的應用程序。其代碼如下所示
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Spring Boot Starter Security
此依賴項用於Spring 安全相關工作。其代碼如下所示
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Spring Boot Starter Web
此依賴關係用於編寫Rest端點。其代碼如下所示 -
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Spring Boot Starter Thyme Leaf
此依賴項用於創建Web應用程序。其代碼如下所示
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Spring Boot Starter Test
此依賴項用於編寫測試用例。其代碼如下所示
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test<artifactId>
</dependency>