Skip to content

Commit bd1733a

Browse files
author
Vasile Baluta
committed
make it deployable in tomcat
1 parent 1bcd8ea commit bd1733a

File tree

2 files changed

+48
-19
lines changed

2 files changed

+48
-19
lines changed

pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<groupId>com.ericsson.ei</groupId>
55
<artifactId>eiffel-intelligence</artifactId>
66
<version>0.0.1</version>
7+
8+
<packaging>war</packaging>
79

810
<parent>
911
<groupId>org.springframework.boot</groupId>
@@ -47,6 +49,12 @@
4749
<dependency>
4850
<groupId>org.springframework.boot</groupId>
4951
<artifactId>spring-boot-starter-web</artifactId>
52+
<exclusions>
53+
<exclusion>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-starter-tomcat</artifactId>
56+
</exclusion>
57+
</exclusions>
5058
</dependency>
5159

5260
<dependency>
@@ -69,6 +77,12 @@
6977
<artifactId>spring-boot-starter-test</artifactId>
7078
<scope>test</scope>
7179
</dependency>
80+
81+
<dependency>
82+
<groupId>org.springframework.boot</groupId>
83+
<artifactId>spring-boot-starter-tomcat</artifactId>
84+
<scope>provided</scope>
85+
</dependency>
7286

7387
<dependency>
7488
<groupId>com.fasterxml.jackson.core</groupId>
@@ -245,6 +259,14 @@
245259
</includes>
246260
</configuration>
247261
</plugin>
262+
263+
<plugin>
264+
<groupId>org.apache.maven.plugins</groupId>
265+
<artifactId>maven-war-plugin</artifactId>
266+
<configuration>
267+
<failOnMissingWebXml>false</failOnMissingWebXml>
268+
</configuration>
269+
</plugin>
248270

249271
</plugins>
250272
</build>

src/main/java/com/ericsson/ei/App.java

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import org.springframework.boot.SpringApplication;
2020
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
import org.springframework.boot.builder.SpringApplicationBuilder;
22+
import org.springframework.boot.web.support.SpringBootServletInitializer;
2123
import org.springframework.scheduling.annotation.EnableAsync;
2224
import org.springframework.scheduling.annotation.EnableScheduling;
2325

@@ -28,24 +30,29 @@
2830
@SpringBootApplication
2931
@EnableAsync
3032
@EnableScheduling
31-
public class App {
32-
33-
public static void main(String[] args) {
34-
35-
List<String> logLevels = new ArrayList<>();
36-
Collections.addAll(logLevels, "ALL", "DEBUG", "ERROR", "FATAL", "INFO", "TRACE", "WARN");
37-
38-
if(args != null && args.length > 0 && logLevels.contains(args[0])) {
39-
System.setProperty("logging.level.root", args[0]);
40-
System.setProperty("logging.level.org.springframework.web", args[0]);
41-
System.setProperty("logging.level.com.ericsson.ei", args[0]);
42-
} else {
43-
System.setProperty("logging.level.root", "OFF");
44-
System.setProperty("logging.level.org.springframework.web", "OFF");
45-
System.setProperty("logging.level.com.ericsson.ei", "OFF");
46-
}
47-
48-
SpringApplication.run(App.class, args);
49-
}
33+
public class App extends SpringBootServletInitializer {
34+
35+
@Override
36+
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
37+
return application.sources(App.class);
38+
}
39+
40+
public static void main(String[] args) {
41+
42+
List<String> logLevels = new ArrayList<>();
43+
Collections.addAll(logLevels, "ALL", "DEBUG", "ERROR", "FATAL", "INFO", "TRACE", "WARN");
44+
45+
if (args != null && args.length > 0 && logLevels.contains(args[0])) {
46+
System.setProperty("logging.level.root", args[0]);
47+
System.setProperty("logging.level.org.springframework.web", args[0]);
48+
System.setProperty("logging.level.com.ericsson.ei", args[0]);
49+
} else {
50+
System.setProperty("logging.level.root", "OFF");
51+
System.setProperty("logging.level.org.springframework.web", "OFF");
52+
System.setProperty("logging.level.com.ericsson.ei", "OFF");
53+
}
54+
55+
SpringApplication.run(App.class, args);
56+
}
5057

5158
}

0 commit comments

Comments
 (0)