Thursday, September 17, 2020

How to Create a WAR file from a Spring Boot Project using Spring Tool Suite (STS)

 From this article, I  try to explain how to create a war file output as your spring boot project output through  the STS. I express this according to my practice and this may be differ with another person.

Follow the below mentioned steps.

01.The main application class should be extended to the SpringBootServletInitializer.

Example:

@SpringBootApplication
public class RippleReturnTransApplication extends SpringBootServletInitializer{

}

02. In your project's pom.xml file, spring-boot-maven-plugin should be included. 

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>

03. In pm.xml file, mention the packaging type as 'war' in the correct place

    <groupId>hggg</groupId>
    <artifactId>Rdddddd</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Rppppp</name>
    <description>App</description>

03. After that, update the maven project. Do: Right click on the project > maven > update project.

04. Now we have prepared the project for building. Now  Do: right click on the project > run as > maven install

Then STS takes few time for the execution. Then it will create the war file on a folder called 'target' inside the project. Now, This war file can be deployed on to a compatible web server.  

Happy Coding!


No comments:

Post a Comment