How to upload a Spring Boot project to a Glassfish or Tomcat server

Asked

Viewed 1,978 times

1

I can run the application normally by the main class with 'Tomcat Embedded' as dependency. However, when trying to run the application on some server the Eclipse IDE itself informs that the application cannot be run on a server. I recognize the ease of using Spring Boot for development and testing, but I would like to upload the application to an existing server along with other applications that would already be running on this server, without the need for another machine. Against this background, Which dependencies should I add or remove in Maven? Should I remove the main class from the application( the one with the 'main' and 'Springapplication.run' method) ? Which settings (in Java) should be added, only those that are essential for the web project.

1 answer

2


In your pom.xml change the packaging from jar to War.

    <groupId>br.com.teste</groupId>
    <artifactId>testex</artifactId>
    <version>0.1-SNAPSHOT</version>
    <packaging>war</packaging>

Set the Tomcat dependency as provided.

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

Done this generates the . War

mvn clean package

A file . War will be generated inside the target folder ready to be deployed in Tomcat.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.