Commit ff602e60 authored by Andy Wilkinson's avatar Andy Wilkinson

Change default version of Jetty to 9.3

Closes gh-5825
parent e1cafb16
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
<jedis.version>2.8.1</jedis.version> <jedis.version>2.8.1</jedis.version>
<jersey.version>2.23</jersey.version> <jersey.version>2.23</jersey.version>
<jest.version>2.0.3</jest.version> <jest.version>2.0.3</jest.version>
<jetty.version>9.2.17.v20160517</jetty.version> <jetty.version>9.3.9.v20160517</jetty.version>
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version> <jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
<jmustache.version>1.12</jmustache.version> <jmustache.version>1.12</jmustache.version>
<jna.version>4.2.2</jna.version> <jna.version>4.2.2</jna.version>
...@@ -1546,17 +1546,6 @@ ...@@ -1546,17 +1546,6 @@
<artifactId>jetty-io</artifactId> <artifactId>jetty-io</artifactId>
<version>${jetty.version}</version> <version>${jetty.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>${jetty.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId> <artifactId>jetty-jmx</artifactId>
......
...@@ -37,9 +37,9 @@ diverge from the defaults. ...@@ -37,9 +37,9 @@ diverge from the defaults.
[[getting-started-system-requirements]] [[getting-started-system-requirements]]
== System Requirements == System Requirements
By default, Spring Boot {spring-boot-version} requires http://www.java.com[Java 7] and 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 Spring Framework {spring-version} or above. You can use Spring Boot with Java 6 with some
configuration. See <<howto.adoc#howto-use-java-6>> for more details. Explicit build support additional configuration. See <<howto.adoc#howto-use-java-6>> for more details. Explicit
is provided for Maven (3.2+) and Gradle (1.12+). 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 TIP: Although you can use Spring Boot with Java 6 or 7, we generally recommend Java 8 if at
all possible. all possible.
...@@ -58,7 +58,11 @@ The following embedded servlet containers are supported out of the box: ...@@ -58,7 +58,11 @@ The following embedded servlet containers are supported out of the box:
|3.0 |3.0
|Java 6+ |Java 6+
|Jetty 9 |Jetty 9.3
|3.1
|Java 8+
|Jetty 9.2
|3.1 |3.1
|Java 7+ |Java 7+
......
...@@ -920,10 +920,67 @@ You can change the Tomcat version by setting the `tomcat.version` property: ...@@ -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"]
----
<properties>
<jetty.version>9.2.17.v20160517</jetty.version>
</properties>
<dependencies>
<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>
</dependencies>
----
[[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]] [[howto-use-jetty-8]]
=== 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 8 works with Spring Boot, but the default is to use Jetty 9.3. If you cannot use
Jetty 9 (for example, because you are using Java 1.6) you will need to change your 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 classpath to reference Jetty 8. You will also need to exclude Jetty's WebSocket-related
dependencies. dependencies.
......
...@@ -117,8 +117,8 @@ The following sample applications are provided: ...@@ -117,8 +117,8 @@ The following sample applications are provided:
| link:spring-boot-sample-jetty8-ssl[spring-boot-sample-jetty8-ssl] | link:spring-boot-sample-jetty8-ssl[spring-boot-sample-jetty8-ssl]
| Embedded Jetty 8 SSL | Embedded Jetty 8 SSL
| link:spring-boot-sample-jetty93[spring-boot-sample-jetty93] | link:spring-boot-sample-jetty92[spring-boot-sample-jetty92]
| Embedded Jetty 9.3 | Embedded Jetty 9.2
| link:spring-boot-sample-jooq[spring-boot-sample-jooq] | link:spring-boot-sample-jooq[spring-boot-sample-jooq]
| Stores data using jOOQ | Stores data using jOOQ
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<module>spring-boot-sample-jetty-ssl</module> <module>spring-boot-sample-jetty-ssl</module>
<module>spring-boot-sample-jetty8</module> <module>spring-boot-sample-jetty8</module>
<module>spring-boot-sample-jetty8-ssl</module> <module>spring-boot-sample-jetty8-ssl</module>
<module>spring-boot-sample-jetty93</module> <module>spring-boot-sample-jetty92</module>
<module>spring-boot-sample-jooq</module> <module>spring-boot-sample-jooq</module>
<module>spring-boot-sample-jpa</module> <module>spring-boot-sample-jpa</module>
<module>spring-boot-sample-jta-atomikos</module> <module>spring-boot-sample-jta-atomikos</module>
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
<artifactId>spring-boot-samples</artifactId> <artifactId>spring-boot-samples</artifactId>
<version>1.4.0.BUILD-SNAPSHOT</version> <version>1.4.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-boot-sample-jetty93</artifactId> <artifactId>spring-boot-sample-jetty92</artifactId>
<name>Spring Boot Jetty 9.3 Sample</name> <name>Spring Boot Jetty 9.2 Sample</name>
<description>Spring Boot Jetty 9.3 Sample</description> <description>Spring Boot Jetty 9.2 Sample</description>
<url>http://projects.spring.io/spring-boot/</url> <url>http://projects.spring.io/spring-boot/</url>
<organization> <organization>
<name>Pivotal Software, Inc.</name> <name>Pivotal Software, Inc.</name>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</organization> </organization>
<properties> <properties>
<main.basedir>${basedir}/../..</main.basedir> <main.basedir>${basedir}/../..</main.basedir>
<jetty.version>9.3.0.v20150612</jetty.version> <jetty.version>9.2.17.v20160517</jetty.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
* limitations under the License. * limitations under the License.
*/ */
package sample.jetty93; package sample.jetty92;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class SampleJetty93Application { public class SampleJetty92Application {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
SpringApplication.run(SampleJetty93Application.class, args); SpringApplication.run(SampleJetty92Application.class, args);
} }
} }
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package sample.jetty93.service; package sample.jetty92.service;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
* limitations under the License. * 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
......
server.compression.enabled: true server.compression.enabled: true
server.compression.min-response-size: 1 server.compression.min-response-size: 1
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package sample.jetty93; package sample.jetty92;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.nio.charset.Charset; import java.nio.charset.Charset;
...@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext @DirtiesContext
public class SampleJetty93ApplicationTests { public class SampleJetty92ApplicationTests {
@LocalServerPort @LocalServerPort
private int port; private int port;
......
...@@ -48,11 +48,11 @@ import org.eclipse.jetty.server.SessionManager; ...@@ -48,11 +48,11 @@ import org.eclipse.jetty.server.SessionManager;
import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.server.handler.HandlerWrapper; 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.server.session.HashSessionManager;
import org.eclipse.jetty.servlet.ErrorPageErrorHandler; import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletMapping; 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.JarResource;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
...@@ -752,50 +752,47 @@ public class JettyEmbeddedServletContainerFactory ...@@ -752,50 +752,47 @@ public class JettyEmbeddedServletContainerFactory
private static class Jetty92GzipHandlerFactory implements GzipHandlerFactory { private static class Jetty92GzipHandlerFactory implements GzipHandlerFactory {
@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<String>(
Arrays.asList(compression.getExcludedUserAgents())));
}
return gzipHandler;
}
}
private static class Jetty93GzipHandlerFactory implements GzipHandlerFactory {
@Override @Override
public HandlerWrapper createGzipHandler(Compression compression) { public HandlerWrapper createGzipHandler(Compression compression) {
try { try {
Class<?> handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_3, Class<?> handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_2,
getClass().getClassLoader()); getClass().getClassLoader());
HandlerWrapper handler = (HandlerWrapper) handlerClass.newInstance(); HandlerWrapper gzipHandler = (HandlerWrapper) handlerClass.newInstance();
ReflectionUtils.findMethod(handlerClass, "setMinGzipSize", int.class) ReflectionUtils.findMethod(handlerClass, "setMinGzipSize", int.class)
.invoke(handler, compression.getMinResponseSize()); .invoke(gzipHandler, compression.getMinResponseSize());
ReflectionUtils ReflectionUtils
.findMethod(handlerClass, "setIncludedMimeTypes", String[].class) .findMethod(handlerClass, "addIncludedMimeTypes", String[].class)
.invoke(handler, new Object[] { compression.getMimeTypes() }); .invoke(gzipHandler, new Object[] { compression.getMimeTypes() });
if (compression.getExcludedUserAgents() != null) { if (compression.getExcludedUserAgents() != null) {
ReflectionUtils ReflectionUtils.findMethod(handlerClass, "setExcluded", Set.class)
.findMethod(handlerClass, "setExcludedAgentPatterns", .invoke(gzipHandler, new HashSet<String>(
String[].class) Arrays.asList(compression.getExcludedUserAgents())));
.invoke(handler,
new Object[] { compression.getExcludedUserAgents() });
} }
return handler; return gzipHandler;
} }
catch (Exception ex) { catch (Exception ex) {
throw new RuntimeException("Failed to configure Jetty 9.3 gzip handler", throw new RuntimeException("Failed to configure Jetty 9.2 gzip handler",
ex); ex);
} }
} }
} }
private static class Jetty93GzipHandlerFactory implements GzipHandlerFactory {
@Override
public HandlerWrapper createGzipHandler(Compression compression) {
GzipHandler handler = new GzipHandler();
handler.setMinGzipSize(compression.getMinResponseSize());
handler.setIncludedMimeTypes(compression.getMimeTypes());
if (compression.getExcludedUserAgents() != null) {
handler.setExcludedAgentPatterns(compression.getExcludedUserAgents());
}
return handler;
}
}
/** /**
* {@link JettyServerCustomizer} to add {@link ForwardedRequestCustomizer}. Only * {@link JettyServerCustomizer} to add {@link ForwardedRequestCustomizer}. Only
* supported with Jetty 9 (hence the inner class) * supported with Jetty 9 (hence the inner class)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment