Skip to content

Commit f9c0c65

Browse files
zxuhansnicoll
authored andcommitted
Document configuring multiple connectors with Jetty
See gh-17144 Signed-off-by: zxuhan7 <zxuhan7@gmail.com>
1 parent 466e11b commit f9c0c65

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

spring-boot-project/spring-boot-docs/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ dependencies {
105105
implementation("org.apache.tomcat.embed:tomcat-embed-core")
106106
implementation("org.assertj:assertj-core")
107107
implementation("org.cache2k:cache2k-spring")
108+
implementation("org.eclipse.jetty:jetty-server")
108109
implementation("org.apache.groovy:groovy")
109110
implementation("org.glassfish.jersey.containers:jersey-container-servlet-core")
110111
implementation("org.glassfish.jersey.core:jersey-server")

spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/webserver.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,15 @@ include-code::MyTomcatConfiguration[]
520520

521521

522522

523+
[[howto.webserver.enable-multiple-connectors-in-jetty]]
524+
== Enable Multiple Connectors with Jetty
525+
526+
You can register additional Jetty javadoc:org.eclipse.jetty.server.Connector[] instances by adding a javadoc:org.springframework.boot.jetty.JettyServerCustomizer[] to the javadoc:org.springframework.boot.jetty.ConfigurableJettyWebServerFactory[], as shown in the following example:
527+
528+
include-code::MyJettyConfiguration[]
529+
530+
531+
523532
[[howto.webserver.enable-tomcat-mbean-registry]]
524533
== Enable Tomcat's MBean Registry
525534

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.howto.webserver.enablemultipleconnectorsinjetty;
18+
19+
import org.eclipse.jetty.server.ServerConnector;
20+
21+
import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory;
22+
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
23+
import org.springframework.context.annotation.Bean;
24+
import org.springframework.context.annotation.Configuration;
25+
26+
@Configuration(proxyBeanMethods = false)
27+
public class MyJettyConfiguration {
28+
29+
@Bean
30+
public WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> connectorCustomizer() {
31+
return (jetty) -> jetty.addServerCustomizers((server) -> {
32+
ServerConnector connector = new ServerConnector(server);
33+
connector.setPort(8081);
34+
server.addConnector(connector);
35+
});
36+
}
37+
38+
}

0 commit comments

Comments
 (0)