diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 806ad9b49d1..b357bda9d63 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -107,7 +107,7 @@ 2.8.1 2.23 2.0.3 - 9.2.17.v20160517 + 9.3.9.v20160517 2.2.0.v201112011158 1.12 4.2.2 @@ -1546,17 +1546,6 @@ jetty-io ${jetty.version} - - org.eclipse.jetty - jetty-jsp - ${jetty.version} - - - org.eclipse.jetty.orbit - javax.servlet - - - org.eclipse.jetty jetty-jmx diff --git a/spring-boot-docs/src/main/asciidoc/getting-started.adoc b/spring-boot-docs/src/main/asciidoc/getting-started.adoc index 1c4455c67d2..9ad86678e90 100644 --- a/spring-boot-docs/src/main/asciidoc/getting-started.adoc +++ b/spring-boot-docs/src/main/asciidoc/getting-started.adoc @@ -37,9 +37,9 @@ diverge from the defaults. [[getting-started-system-requirements]] == System Requirements By default, Spring Boot {spring-boot-version} requires http://www.java.com[Java 7] and -Spring Framework {spring-version} or above. You can use Spring Boot with Java 6 with some additional -configuration. See <> for more details. Explicit build support -is provided for Maven (3.2+) and Gradle (1.12+). +Spring Framework {spring-version} or above. You can use Spring Boot with Java 6 with some +additional configuration. See <> for more details. Explicit +build support is provided for Maven (3.2+) and Gradle (1.12+). TIP: Although you can use Spring Boot with Java 6 or 7, we generally recommend Java 8 if at all possible. @@ -58,7 +58,11 @@ The following embedded servlet containers are supported out of the box: |3.0 |Java 6+ -|Jetty 9 +|Jetty 9.3 +|3.1 +|Java 8+ + +|Jetty 9.2 |3.1 |Java 7+ diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 9d963d93544..35febac3980 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -920,10 +920,67 @@ You can change the Tomcat version by setting the `tomcat.version` property: +[[howto-use-jetty-9.2]] +=== Use Jetty 9.2 +Jetty 9.2 works with Spring Boot, but the default is to use Jetty 9.3. If you cannot use +Jetty 9.3 (for example, because you are using Java 7) you will need to change your +classpath to reference Jetty 9.2. + + + +[[howto-use-jetty-9.2-maven]] +==== Use Jetty 9.2 with Maven + +If you are using the starters and parent you can just add the Jetty starter and override +the `jetty.version` property: + +[source,xml,indent=0,subs="verbatim,quotes,attributes"] +---- + + 9.2.17.v20160517 + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + org.springframework.boot + spring-boot-starter-jetty + + +---- + + + +[[howto-use-jetty-9.2-gradle]] +==== Use Jetty 9.2 with Gradle + +You can set the `jetty.version` property. For example, for a simple webapp or service: + +[source,groovy,indent=0,subs="verbatim,quotes,attributes"] +---- + ext['jetty.version'] = '9.2.17.v20160517' + dependencies { + compile ('org.springframework.boot:spring-boot-starter-web') { + exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat' + } + compile ('org.springframework.boot:spring-boot-starter-jetty') + } +---- + + + [[howto-use-jetty-8]] === Use Jetty 8 -Jetty 8 works with Spring Boot, but the default is to use Jetty 9. If you cannot use -Jetty 9 (for example, because you are using Java 1.6) you will need to change your +Jetty 8 works with Spring Boot, but the default is to use Jetty 9.3. If you cannot use +Jetty 9.3 (for example, because you are using Java 1.6) you will need to change your classpath to reference Jetty 8. You will also need to exclude Jetty's WebSocket-related dependencies. diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc index ab335f407be..1ebef9e19d6 100644 --- a/spring-boot-samples/README.adoc +++ b/spring-boot-samples/README.adoc @@ -117,8 +117,8 @@ The following sample applications are provided: | link:spring-boot-sample-jetty8-ssl[spring-boot-sample-jetty8-ssl] | Embedded Jetty 8 SSL -| link:spring-boot-sample-jetty93[spring-boot-sample-jetty93] -| Embedded Jetty 9.3 +| link:spring-boot-sample-jetty92[spring-boot-sample-jetty92] +| Embedded Jetty 9.2 | link:spring-boot-sample-jooq[spring-boot-sample-jooq] | Stores data using jOOQ diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 8f94c03d267..5ce36b613f4 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -58,7 +58,7 @@ spring-boot-sample-jetty-ssl spring-boot-sample-jetty8 spring-boot-sample-jetty8-ssl - spring-boot-sample-jetty93 + spring-boot-sample-jetty92 spring-boot-sample-jooq spring-boot-sample-jpa spring-boot-sample-jta-atomikos diff --git a/spring-boot-samples/spring-boot-sample-jetty93/pom.xml b/spring-boot-samples/spring-boot-sample-jetty92/pom.xml similarity index 88% rename from spring-boot-samples/spring-boot-sample-jetty93/pom.xml rename to spring-boot-samples/spring-boot-sample-jetty92/pom.xml index c3e203b9b63..e69086de63d 100644 --- a/spring-boot-samples/spring-boot-sample-jetty93/pom.xml +++ b/spring-boot-samples/spring-boot-sample-jetty92/pom.xml @@ -7,9 +7,9 @@ spring-boot-samples 1.4.0.BUILD-SNAPSHOT - spring-boot-sample-jetty93 - Spring Boot Jetty 9.3 Sample - Spring Boot Jetty 9.3 Sample + spring-boot-sample-jetty92 + Spring Boot Jetty 9.2 Sample + Spring Boot Jetty 9.2 Sample http://projects.spring.io/spring-boot/ Pivotal Software, Inc. @@ -17,7 +17,7 @@ ${basedir}/../.. - 9.3.0.v20150612 + 9.2.17.v20160517 diff --git a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/SampleJetty93Application.java b/spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/SampleJetty92Application.java similarity index 81% rename from spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/SampleJetty93Application.java rename to spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/SampleJetty92Application.java index ef88857e694..4295be16d82 100644 --- a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/SampleJetty93Application.java +++ b/spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/SampleJetty92Application.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,16 +14,16 @@ * limitations under the License. */ -package sample.jetty93; +package sample.jetty92; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class SampleJetty93Application { +public class SampleJetty92Application { public static void main(String[] args) throws Exception { - SpringApplication.run(SampleJetty93Application.class, args); + SpringApplication.run(SampleJetty92Application.class, args); } } diff --git a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/service/HelloWorldService.java b/spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/service/HelloWorldService.java similarity index 90% rename from spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/service/HelloWorldService.java rename to spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/service/HelloWorldService.java index 3aaed9404a4..e8e4bd9e83e 100644 --- a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/service/HelloWorldService.java +++ b/spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package sample.jetty93.service; +package sample.jetty92.service; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java b/spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/web/SampleController.java similarity index 93% rename from spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java rename to spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/web/SampleController.java index 3368dd849be..ce573c062be 100644 --- a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/web/SampleController.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package sample.jetty93.web; +package sample.jetty92.web; -import sample.jetty93.service.HelloWorldService; +import sample.jetty92.service.HelloWorldService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; diff --git a/spring-boot-samples/spring-boot-sample-jetty92/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-jetty92/src/main/resources/application.properties new file mode 100644 index 00000000000..09ab26beccd --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-jetty92/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.compression.enabled: true +server.compression.min-response-size: 1 diff --git a/spring-boot-samples/spring-boot-sample-jetty93/src/test/java/sample/jetty93/SampleJetty93ApplicationTests.java b/spring-boot-samples/spring-boot-sample-jetty92/src/test/java/sample/jetty92/SampleJetty92ApplicationTests.java similarity index 97% rename from spring-boot-samples/spring-boot-sample-jetty93/src/test/java/sample/jetty93/SampleJetty93ApplicationTests.java rename to spring-boot-samples/spring-boot-sample-jetty92/src/test/java/sample/jetty92/SampleJetty92ApplicationTests.java index 4ca1267a1c7..2ba84b99401 100644 --- a/spring-boot-samples/spring-boot-sample-jetty93/src/test/java/sample/jetty93/SampleJetty93ApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-jetty92/src/test/java/sample/jetty92/SampleJetty92ApplicationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package sample.jetty93; +package sample.jetty92; import java.io.ByteArrayInputStream; import java.nio.charset.Charset; @@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext -public class SampleJetty93ApplicationTests { +public class SampleJetty92ApplicationTests { @LocalServerPort private int port; diff --git a/spring-boot-samples/spring-boot-sample-jetty93/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-jetty93/src/main/resources/application.properties deleted file mode 100644 index f0cf3217203..00000000000 --- a/spring-boot-samples/spring-boot-sample-jetty93/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -server.compression.enabled: true -server.compression.min-response-size: 1 \ No newline at end of file diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java index f1c8e35bb98..ff0cef47b36 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java @@ -48,11 +48,11 @@ import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.server.handler.HandlerWrapper; +import org.eclipse.jetty.server.handler.gzip.GzipHandler; import org.eclipse.jetty.server.session.HashSessionManager; import org.eclipse.jetty.servlet.ErrorPageErrorHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletMapping; -import org.eclipse.jetty.servlets.gzip.GzipHandler; import org.eclipse.jetty.util.resource.JarResource; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.ssl.SslContextFactory; @@ -754,14 +754,26 @@ public class JettyEmbeddedServletContainerFactory @Override public HandlerWrapper createGzipHandler(Compression compression) { - GzipHandler gzipHandler = new GzipHandler(); - gzipHandler.setMinGzipSize(compression.getMinResponseSize()); - gzipHandler.addIncludedMimeTypes(compression.getMimeTypes()); - if (compression.getExcludedUserAgents() != null) { - gzipHandler.setExcluded(new HashSet( - Arrays.asList(compression.getExcludedUserAgents()))); + try { + Class handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_2, + getClass().getClassLoader()); + HandlerWrapper gzipHandler = (HandlerWrapper) handlerClass.newInstance(); + ReflectionUtils.findMethod(handlerClass, "setMinGzipSize", int.class) + .invoke(gzipHandler, compression.getMinResponseSize()); + ReflectionUtils + .findMethod(handlerClass, "addIncludedMimeTypes", String[].class) + .invoke(gzipHandler, new Object[] { compression.getMimeTypes() }); + if (compression.getExcludedUserAgents() != null) { + ReflectionUtils.findMethod(handlerClass, "setExcluded", Set.class) + .invoke(gzipHandler, new HashSet( + Arrays.asList(compression.getExcludedUserAgents()))); + } + return gzipHandler; + } + catch (Exception ex) { + throw new RuntimeException("Failed to configure Jetty 9.2 gzip handler", + ex); } - return gzipHandler; } } @@ -770,28 +782,13 @@ public class JettyEmbeddedServletContainerFactory @Override public HandlerWrapper createGzipHandler(Compression compression) { - try { - Class handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_3, - getClass().getClassLoader()); - HandlerWrapper handler = (HandlerWrapper) handlerClass.newInstance(); - ReflectionUtils.findMethod(handlerClass, "setMinGzipSize", int.class) - .invoke(handler, compression.getMinResponseSize()); - ReflectionUtils - .findMethod(handlerClass, "setIncludedMimeTypes", String[].class) - .invoke(handler, new Object[] { compression.getMimeTypes() }); - if (compression.getExcludedUserAgents() != null) { - ReflectionUtils - .findMethod(handlerClass, "setExcludedAgentPatterns", - String[].class) - .invoke(handler, - new Object[] { compression.getExcludedUserAgents() }); - } - return handler; - } - catch (Exception ex) { - throw new RuntimeException("Failed to configure Jetty 9.3 gzip handler", - ex); + GzipHandler handler = new GzipHandler(); + handler.setMinGzipSize(compression.getMinResponseSize()); + handler.setIncludedMimeTypes(compression.getMimeTypes()); + if (compression.getExcludedUserAgents() != null) { + handler.setExcludedAgentPatterns(compression.getExcludedUserAgents()); } + return handler; } }