瀏覽代碼

Make end state simpler

Dave Syer 10 年之前
父節點
當前提交
63197fa668
共有 3 個文件被更改,包括 1 次插入112 次删除
  1. 0
    94
      README.adoc
  2. 1
    6
      complete/build.gradle
  3. 0
    12
      complete/pom.xml

+ 0
- 94
README.adoc 查看文件

@@ -147,100 +147,6 @@ $ curl localhost:8080
147 147
 Greetings from Spring Boot!
148 148
 ....
149 149
 
150
-== Switch from Tomcat to Jetty
151
-What if you prefer Jetty over Tomcat? Jetty and Tomcat are both compliant servlet containers, so it should be easy to switch. With Spring Boot, it is!
152
-
153
-Change your `build.gradle` to exclude Tomcat then add Jetty to the list of dependencies:
154
-
155
-[source,groovy]
156
-----
157
-include::complete/build.gradle[tag=jetty]
158
-----
159
-
160
-If you are using Maven, the changes look like this:
161
-
162
-[source,xml]
163
-----
164
-include::complete/pom.xml[tag=jetty]
165
-----
166
-
167
-This change isn't about comparing Tomcat vs. Jetty. Instead, it demonstrates how Spring Boot reacts to what is on your classpath. And by no means does it assert which servlet container is right for you.
168
-
169
-As you can see below, the code is the same as before:
170
-
171
-`src/main/java/hello/Application.java`
172
-[source,java]
173
-----
174
-include::complete/src/main/java/hello/Application.java[]
175
-----
176
-    
177
-
178
-== Re-run the application
179
-
180
-Run the app again:
181
-
182
-[subs="attributes"]
183
-----
184
-./gradlew build && java -jar build/libs/{project_id}-0.1.0.jar
185
-----
186
-
187
-If you are using Maven, execute:
188
-
189
-[subs="attributes"]
190
-----
191
-mvn package && java -jar target/{project_id}-0.1.0.jar
192
-----
193
-
194
-Now check out the output:
195
-
196
-....
197
-Let's inspect the beans provided by Spring Boot:
198
-application
199
-beanNameHandlerMapping
200
-defaultServletHandlerMapping
201
-dispatcherServlet
202
-embeddedServletContainerCustomizerBeanPostProcessor
203
-faviconHandlerMapping
204
-faviconRequestHandler
205
-handlerExceptionResolver
206
-helloController
207
-hiddenHttpMethodFilter
208
-httpRequestHandlerAdapter
209
-jettyEmbeddedServletContainerFactory
210
-messageSource
211
-mvcContentNegotiationManager
212
-mvcConversionService
213
-mvcValidator
214
-org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration
215
-org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
216
-org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
217
-org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$DispatcherServletConfiguration
218
-org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedJetty
219
-org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
220
-org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
221
-org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter
222
-org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter$FaviconConfiguration
223
-org.springframework.boot.context.embedded.properties.ServerProperties
224
-org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor
225
-org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor
226
-org.springframework.context.annotation.internalAutowiredAnnotationProcessor
227
-org.springframework.context.annotation.internalCommonAnnotationProcessor
228
-org.springframework.context.annotation.internalConfigurationAnnotationProcessor
229
-org.springframework.context.annotation.internalRequiredAnnotationProcessor
230
-org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
231
-propertySourcesBinder
232
-propertySourcesPlaceholderConfigurer
233
-requestMappingHandlerAdapter
234
-requestMappingHandlerMapping
235
-resourceHandlerMapping
236
-simpleControllerHandlerAdapter
237
-viewControllerHandlerMapping
238
-....
239
-
240
-There is little change from the previous output, except there is no longer a `tomcatEmbeddedServletContainerFactory`. Instead, there is a new `jettyEmbeddedServletContainer`. 
241
-
242
-Otherwise, everything is the same, as it should be. Most beans listed above provide Spring MVC's production-grade features. Simply swapping one part, the servlet container, shouldn't cause a system-wide ripple.
243
-
244 150
 == Add production-grade services
245 151
 If you are building a web site for your business, you probably need to add some management services. Spring Boot provides several out of the box with its https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/README.md[actuator module], such as health, audits, beans, and more.
246 152
 

+ 1
- 6
complete/build.gradle 查看文件

@@ -24,12 +24,7 @@ repositories {
24 24
 }
25 25
 
26 26
 dependencies {
27
-    // tag::jetty[]
28
-    compile("org.springframework.boot:spring-boot-starter-web") {
29
-        exclude module: "spring-boot-starter-tomcat"
30
-    }
31
-    compile("org.springframework.boot:spring-boot-starter-jetty")
32
-    // end::jetty[]
27
+    compile("org.springframework.boot:spring-boot-starter-web")
33 28
     // tag::actuator[]
34 29
     compile("org.springframework.boot:spring-boot-starter-actuator")
35 30
     // end::actuator[]

+ 0
- 12
complete/pom.xml 查看文件

@@ -14,22 +14,10 @@
14 14
     </parent>
15 15
 
16 16
     <dependencies>
17
-	    <!-- tag::jetty[] -->
18 17
         <dependency>
19 18
             <groupId>org.springframework.boot</groupId>
20 19
             <artifactId>spring-boot-starter-web</artifactId>
21
-            <exclusions>
22
-                <exclusion>
23
-                    <groupId>org.springframework.boot</groupId>
24
-                    <artifactId>spring-boot-starter-tomcat</artifactId>
25
-                </exclusion>
26
-	    </exclusions>
27 20
         </dependency>
28
-        <dependency>
29
-            <groupId>org.springframework.boot</groupId>
30
-            <artifactId>spring-boot-starter-jetty</artifactId>
31
-        </dependency>
32
-        <!-- end::jetty[] -->
33 21
         <!-- tag::actuator[] -->
34 22
         <dependency>
35 23
             <groupId>org.springframework.boot</groupId>