English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
spring-boot-starter-webには2つの重要な機能があります:
Web開発と互換性があります 自動構成
Webアプリケーションを開発するには、pom.xmlファイルに以下の依存関係を追加する必要があります:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.2.2.RELEASE</version> </dependency>
Spring webの起動プログラムは、Spring MVC、REST、Tomcatを使用してデフォルトのエンブッドサーバーとして提供されます。単一のspring-boot-starter-web依存関係は可伝播的に取得し、Web開発に関連するすべての依存関係を取得します。また、ビルド依存関係の数を減少させます。spring-boot-starter-webは以下の内容に依存して可伝播的に提供されます:
org.springframework.boot: spring-boot-starter org.springframework.boot: spring-boot-starter-tomcat org.springframework.boot: spring-boot-starter-validation com.fasterxml.jackson.core: jackson-databind org.springframework: spring-web org.springframework: spring-webmvc
デフォルトでは、spring-boot-starter-web包含以下tomcat服务器依赖项:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <version>2webには以下のTomcatサーバー依存関係が含まれています:/version> <scope>compile</scope> </dependency>
spring-boot-starter-.0.0.RELEASE<
webは以下の項目を自動的に設定します: スケジューラーサervlet エラーページ 静的依存関係を管理するためのWeb JAR
Spring Boot内蔵Webサーバー を使用して含めることができます 各Spring Bootアプリケーションには内蔵サーバーが含まれています。内蔵サーバーはデプロイ可能なアプリケーションの一部として内蔵されます。内蔵サーバーの利点は、環境にサーバーを事前にインストールする必要がないことです。Spring Bootを使用すると、デフォルトの内蔵サーバーは以下の通りです
Jettyサーバー 。Spring Bootは他の2つの内蔵サーバーもサポートしています:
。 を使用して他の内蔵Webサーバーリアクタ spring-boot-starter-web servletスタック spring-boot-starter-tomcat を含めることで を使用して含めることができます Tomcat spring-boot-starter-jetty 、しかし、以下を使用して spring -boot-starter-または undertow
。 に対してリアクタ spring-boot-starter-アプリケーション、 webflux webflux spring-boot-starter-包括-reactor netty 、しかし、以下を使用してReactor Nettyを実現できます spring-boot-starter-tomcat、spring-boot-starter-jetty、
Spring Bootは、以下をサポートしています Jettyサーバー。HTTPサーバーおよびServletコンテナで、静的および動的コンテンツを提供する機能があります。
アプリケーションにJettyサーバーを追加するには、以下を追加する必要があります。 spring-boot-starter-jetty 依存関係を確認してください。
覚えておいてください: 。アプリケーションでJettyサーバーを使用する際は、以下の デフォルトのTomcatサーバーを除外します spring-boot-starter-web 。サーバー間の衝突を避けます。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency>
さらに、以下を使用できます application.properties ファイルはカスタマイズされたJettyサーバーの動作を定義します。
Spring Bootは、別名 Undertow サーバー。それもJettyのような内蔵Webサーバーです。Javaで書かれており、JBossが管理・スポンサーしています。Undertowサーバーの主な利点は以下の通りです:
HTTPをサポートする/2 HTTPアップグレードサポート Websocketサポート Servletへのサポートを提供 4.0のサポート 柔軟 内蔵可能
覚えておいてください: : アプリケーションでUndertowサーバーを使用する際は、以下から確認してください spring-boot-starter中デフォルトのTomcatサーバーを除外します -web。サーバー間の衝突を避けます。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> </dependency>
さらに、以下を使用できます application.properties ファイルはカスタマイズされたUndertowサーバーの動作を定義します。
spring-boot-starter-webにはspring web依存関係が含まれており、その中にはspringが含まれます。-boot-starter-tomcat。 spring-boot-starter-webは以下の内容を含んでいます:
spring-boot-starter jackson spring-core spring-mvc spring-boot-starter-tomcat
spring-boot-starter-tomcat Tomcatサーバーに関連するすべてを含んでいます。
core el logging websocket
starter-tomcatは以下の依存関係を持っています:
<dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-core</artifactId> <version>8.5.23</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-el</artifactId> <version>8.5.23</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-websocket</artifactId> <version>8.5.23</version> <scope>compile</scope> </dependency>
以下のように使用することもできます。 spring-mvc 組み込みのTomcatサーバーを使用しない場合、以下のように行います。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>