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

0

I can run the application normally through the main class with 'tomcat embedded' as a dependency.     However when trying to run the application on some server the IDE itself Eclipse informs that the application can not be run on a server.     I recognize the ease of using Spring Boot for development and testing, but would like to upload the application to an existing server next to other applications that would already be running on this server, without the need for another machine.     Considering this scenario,     Which dependencies should I add or remove on maven?     Should I remove the main class of the application (which has the method 'main' and 'SpringApplication.run')?     What settings (in Java) should be added, only those that are essential for the web project.

    
asked by anonymous 07.10.2016 / 15:31

1 answer

2

In your pom.xml switch the jar packaging to war.

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

Put the tomcat dependency as provided.

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

Once this is done, generate .war

  

mvn clean package

A .war file will be generated inside the target folder ready to be deployed to tomcat.

    
07.10.2016 / 19:27