Skip to content

Commit 5664322

Browse files
committed
Add simple war sample
1 parent 676ff75 commit 5664322

File tree

5 files changed

+151
-0
lines changed

5 files changed

+151
-0
lines changed

spring-boot-samples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<module>spring-boot-sample-undertow</module>
6969
<module>spring-boot-sample-undertow-ssl</module>
7070
<module>spring-boot-sample-velocity</module>
71+
<module>spring-boot-sample-war</module>
7172
<module>spring-boot-sample-web-freemarker</module>
7273
<module>spring-boot-sample-web-groovy-templates</module>
7374
<module>spring-boot-sample-web-method-security</module>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<!-- Your own application should inherit from spring-boot-starter-parent -->
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-samples</artifactId>
9+
<version>1.2.7.BUILD-SNAPSHOT</version>
10+
</parent>
11+
<artifactId>spring-boot-sample-war</artifactId>
12+
<packaging>war</packaging>
13+
<name>Spring Boot War Sample</name>
14+
<description>Spring Boot War Sample</description>
15+
<url>http://projects.spring.io/spring-boot/</url>
16+
<organization>
17+
<name>Pivotal Software, Inc.</name>
18+
<url>http://www.spring.io</url>
19+
</organization>
20+
<properties>
21+
<main.basedir>${basedir}/../..</main.basedir>
22+
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
23+
</properties>
24+
<dependencies>
25+
<!-- Compile -->
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>javax.servlet</groupId>
32+
<artifactId>javax.servlet-api</artifactId>
33+
<scope>provided</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-web</artifactId>
38+
<exclusions>
39+
<exclusion>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-tomcat</artifactId>
42+
</exclusion>
43+
</exclusions>
44+
</dependency>
45+
</dependencies>
46+
<build>
47+
<plugins>
48+
<plugin>
49+
<groupId>org.springframework.boot</groupId>
50+
<artifactId>spring-boot-maven-plugin</artifactId>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
<profiles>
55+
<profile>
56+
<id>tomcat</id>
57+
<dependencies>
58+
<dependency>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-starter-tomcat</artifactId>
61+
<scope>provided</scope>
62+
</dependency>
63+
</dependencies>
64+
</profile>
65+
<profile>
66+
<id>jetty</id>
67+
<dependencies>
68+
<dependency>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-starter-jetty</artifactId>
71+
<scope>provided</scope>
72+
</dependency>
73+
</dependencies>
74+
</profile>
75+
<profile>
76+
<id>undertow</id>
77+
<dependencies>
78+
<dependency>
79+
<groupId>org.springframework.boot</groupId>
80+
<artifactId>spring-boot-starter-undertow</artifactId>
81+
<scope>provided</scope>
82+
</dependency>
83+
</dependencies>
84+
</profile>
85+
</profiles>
86+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2012-2015 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+
* http://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 sample.war;
18+
19+
import org.springframework.web.bind.annotation.RequestMapping;
20+
import org.springframework.web.bind.annotation.RestController;
21+
22+
@RestController
23+
public class MyController {
24+
25+
@RequestMapping("/")
26+
public String hello() {
27+
return "Hello World!";
28+
}
29+
30+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2015 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+
* http://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 sample.war;
18+
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
import org.springframework.boot.context.web.SpringBootServletInitializer;
22+
23+
/**
24+
* Sample WAR application
25+
*/
26+
@SpringBootApplication
27+
public class SampleWarApplication extends SpringBootServletInitializer {
28+
29+
public static void main(String[] args) {
30+
SpringApplication.run(SampleWarApplication.class, args);
31+
}
32+
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello WebApp

0 commit comments

Comments
 (0)