Skip to content

Commit 9c015aa

Browse files
committed
Initial commit
0 parents  commit 9c015aa

4 files changed

Lines changed: 91 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/*
2+
**/target/*
3+
*.iml

pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>sparkjava-hello-world</groupId>
8+
<artifactId>sparkjava-hello-world</artifactId>
9+
<version>1.0</version>
10+
<packaging>war</packaging>
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>com.sparkjava</groupId>
15+
<artifactId>spark-core</artifactId>
16+
<version>2.3</version>
17+
</dependency>
18+
</dependencies>
19+
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.1</version>
26+
<configuration>
27+
<source>1.8</source>
28+
<target>1.8</target>
29+
<optimize>true</optimize>
30+
<debug>true</debug>
31+
</configuration>
32+
</plugin>
33+
<plugin>
34+
<groupId>org.apache.maven.plugins</groupId>
35+
<artifactId>maven-enforcer-plugin</artifactId>
36+
<version>1.3.1</version>
37+
<executions>
38+
<execution>
39+
<id>enforce-java</id>
40+
<goals>
41+
<goal>enforce</goal>
42+
</goals>
43+
<configuration>
44+
<rules>
45+
<requireJavaVersion>
46+
<version>[1.8,)</version>
47+
</requireJavaVersion>
48+
</rules>
49+
</configuration>
50+
</execution>
51+
</executions>
52+
</plugin>
53+
</plugins>
54+
</build>
55+
</project>

src/main/java/HelloWorld.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import spark.servlet.SparkApplication;
2+
3+
import static spark.Spark.get;
4+
5+
public class HelloWorld implements SparkApplication {
6+
public static void main(String[] args) {
7+
new HelloWorld().init();
8+
}
9+
10+
@Override
11+
public void init() {
12+
get("/hello", (req, res) -> "Hello World");
13+
}
14+
}

src/main/webapp/WEB-INF/web.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
4+
version="3.0">
5+
6+
<filter>
7+
<filter-name>SparkFilter</filter-name>
8+
<filter-class>spark.servlet.SparkFilter</filter-class>
9+
<init-param>
10+
<param-name>applicationClass</param-name>
11+
<param-value>HelloWorld</param-value>
12+
</init-param>
13+
</filter>
14+
15+
<filter-mapping>
16+
<filter-name>SparkFilter</filter-name>
17+
<url-pattern>/*</url-pattern>
18+
</filter-mapping>
19+
</web-app>

0 commit comments

Comments
 (0)