Monday, September 9, 2019
Spring Boot WAR file is not working after tomcat deployment in Microsoft azure:
Jar is working fine. But if I create war file, then it is not working.
For Maven Users:
for creating war file, I need to change the following.
1. In pom.xml file, add [packaging] tag file.
2. Add start-class in properties section of pom.xml file
3. Main Application class should look like below:
1. Add plugin to build.gradle
2. Add provided dependency to tomcat
For Maven Users:
================
for creating war file, I need to change the following.
1. In pom.xml file, add [packaging] tag file.
<packaging>war</packaging>
2. Add start-class in properties section of pom.xml file
<properties>
<start-class>mypackage.App</start-class>
</properties>
3. Main Application class should look like below:
@SpringBootApplicationResource Link:
public class Application extends SpringBootServletInitializer {
/**
* Used when run as JAR
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
/**
* Used when run as WAR
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
For Gradle Users:
1. Add plugin to build.gradle
apply plugin: 'war'
2. Add provided dependency to tomcat
dependencies {
// other dependencies
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
}
Subscribe to:
Posts (Atom)