parent
e1cafb16ba
commit
ff602e60a0
|
@ -107,7 +107,7 @@
|
|||
<jedis.version>2.8.1</jedis.version>
|
||||
<jersey.version>2.23</jersey.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>
|
||||
<jmustache.version>1.12</jmustache.version>
|
||||
<jna.version>4.2.2</jna.version>
|
||||
|
@ -1546,17 +1546,6 @@
|
|||
<artifactId>jetty-io</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</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>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jmx</artifactId>
|
||||
|
|
|
@ -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 <<howto.adoc#howto-use-java-6>> 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 <<howto.adoc#howto-use-java-6>> 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+
|
||||
|
||||
|
|
|
@ -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]]
|
||||
=== 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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<module>spring-boot-sample-jetty-ssl</module>
|
||||
<module>spring-boot-sample-jetty8</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-jpa</module>
|
||||
<module>spring-boot-sample-jta-atomikos</module>
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<artifactId>spring-boot-samples</artifactId>
|
||||
<version>1.4.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-sample-jetty93</artifactId>
|
||||
<name>Spring Boot Jetty 9.3 Sample</name>
|
||||
<description>Spring Boot Jetty 9.3 Sample</description>
|
||||
<artifactId>spring-boot-sample-jetty92</artifactId>
|
||||
<name>Spring Boot Jetty 9.2 Sample</name>
|
||||
<description>Spring Boot Jetty 9.2 Sample</description>
|
||||
<url>http://projects.spring.io/spring-boot/</url>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
|
@ -17,7 +17,7 @@
|
|||
</organization>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
<jetty.version>9.3.0.v20150612</jetty.version>
|
||||
<jetty.version>9.2.17.v20160517</jetty.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
|
@ -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;
|
|
@ -0,0 +1,2 @@
|
|||
server.compression.enabled: true
|
||||
server.compression.min-response-size: 1
|
|
@ -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;
|
|
@ -1,2 +0,0 @@
|
|||
server.compression.enabled: true
|
||||
server.compression.min-response-size: 1
|
|
@ -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<String>(
|
||||
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<String>(
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue