Skip to content

Commit 6ed31ac

Browse files
Adding jetty server
1 parent 7e7e405 commit 6ed31ac

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed

pom.xml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-starter-parent</artifactId>
9+
<version>2.2.6.RELEASE</version>
10+
<relativePath /> <!-- lookup parent from repository -->
11+
</parent>
12+
<groupId>com.javaprogram</groupId>
13+
<artifactId>spring-boot-app</artifactId>
14+
<version>0.0.1-SNAPSHOT</version>
15+
<name>spring-boot-app</name>
16+
<description>Demo project for Spring Boot</description>
17+
18+
<properties>
19+
<java.version>1.8</java.version>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-web</artifactId>
26+
<exclusions>
27+
<exclusion>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-tomcat</artifactId>
30+
</exclusion>
31+
</exclusions>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-jetty</artifactId>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.projectlombok</groupId>
40+
<artifactId>lombok</artifactId>
41+
<optional>true</optional>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-test</artifactId>
46+
<scope>test</scope>
47+
<exclusions>
48+
<exclusion>
49+
<groupId>org.junit.vintage</groupId>
50+
<artifactId>junit-vintage-engine</artifactId>
51+
</exclusion>
52+
</exclusions>
53+
</dependency>
54+
</dependencies>
55+
56+
<build>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-maven-plugin</artifactId>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
65+
</project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.javaprogram.springbootapp;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
6+
import org.springframework.boot.web.server.ErrorPage;
7+
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.http.HttpStatus;
10+
11+
12+
@SpringBootApplication
13+
public class SpringBootAppApplication {
14+
15+
public static void main(String[] args) {
16+
SpringApplication.run(SpringBootAppApplication.class, args);
17+
}
18+
19+
/*
20+
21+
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
22+
JettyEmbeddedServletContainerFactory jettyContainer =
23+
new JettyEmbeddedServletContainerFactory();
24+
25+
jettyContainer.setPort(9000);
26+
jettyContainer.setContextPath("/home");
27+
return jettyContainer;
28+
}
29+
30+
*/
31+
32+
@Bean
33+
public ConfigurableServletWebServerFactory webServerFactory()
34+
{
35+
JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
36+
factory.setPort(9000);
37+
factory.setContextPath("/myapp");
38+
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html"));
39+
return factory;
40+
}
41+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#Jetty Configurations
2+
3+
server.port=8082
4+
server.servlet.context-path=/home
5+
server.jetty.acceptors=1
6+
#Number of acceptor threads to use. When the value is -1.
7+
8+
server.jetty.accesslog.append=false
9+
# Append to log.
10+
11+
server.jetty.accesslog.date-format=dd/MMM/yyyy:HH:mm:ss Z
12+
# Timestamp format of the request log.
13+
14+
server.jetty.accesslog.enabled=false
15+
# Enable access log.
16+
17+
server.jetty.accesslog.extended-format=false
18+
# Enable extended NCSA format.
19+
20+
server.jetty.accesslog.file-date-format=dd/MMM/yyyy
21+
# Date format to place in a log filename.
22+
23+
server.jetty.accesslog.filename= app.log
24+
# Log filename. If not specified, logs redirect to "System.err".
25+
26+
server.jetty.accesslog.locale=IN
27+
# Locale of the request log.
28+
29+
server.jetty.accesslog.log-cookies=false
30+
# Enable logging of the request cookies.
31+
32+
server.jetty.accesslog.log-latency=false
33+
# Enable logging of request processing time.
34+
35+
server.jetty.accesslog.log-server=false
36+
# Enable logging of the request hostname.
37+
38+
server.jetty.accesslog.retention-period=31
39+
server.jetty.accesslog.time-zone=GMT
40+
# Timezone of the request log.
41+
42+
#server.jetty.max-http-post-size=200000B # Maximum size of the HTTP post or put content.
43+
# Number of selector threads to use. When the value is -1.
44+
server.jetty.selectors=2
45+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.javaprogram.springbootapp;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.boot.test.context.SpringBootTest;
5+
6+
@SpringBootTest
7+
class SpringBootAppApplicationTests {
8+
9+
@Test
10+
void contextLoads() {
11+
}
12+
13+
}

0 commit comments

Comments
 (0)