-1

I have recently created a web application using spring mvc, gradle and tomcat to host it. I have been trying to create a war file of the web application which can be executed on its own with no need to have gradle and tomcat installed on your computer.

For example running java -jar <path-to-war> and the server will be running on the localhost port specified.

What is the best way to approach this?

Sahil Chabria
  • 13
  • 1
  • 6

1 Answers1

1

use spring boot, comes with embedded tomcat,include below in pom and

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
</dependency>

Main method

@SpringBootApplication
public class AppApplication {

public static void main(String[] args) {
    SpringApplication.run(AppApplication.class, args);
}
}