0

I would like to use the Spring Initializr to create WAR for tomcat...
Our DevOps are still not used to the idea of running java as a standalone and would like to have the application as a WAR in tomcat

I was able to produce a project but it seems like its producing a standalone spring boot application

I still want to use Spring Initializr to produce all the dependencies like :

  • Rest Repositories
  • JDBC template
  • Quartz
  • REST

One solution is to create a dynamic web project in eclipse and use Spring Initializr then just copy all the pom dependency into the dynamic web project is there a better way?

Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89
JavaSheriff
  • 7,074
  • 20
  • 89
  • 159
  • 2
    Select **More Options**, change JAR to WAR in the **packaging** section... – M. Deinum Apr 09 '19 at 19:02
  • 1
    Also can create war with maven plugins – Dred Apr 09 '19 at 19:08
  • Thank you Deinum but how do i get the Eclipse project out of this? – JavaSheriff Apr 09 '19 at 21:12
  • Just import the project... It is no more complex than that. Eclipse will detect the fact it is a war project and make it a web project. – M. Deinum Apr 10 '19 at 17:39
  • no its not doing it. it will not create it as dynamic web project and will not add it to tomcat, i have posted a new question on this https://stackoverflow.com/questions/55616337/correct-way-of-creating-spring-initialize-project-and-using-it-as-a-dynamic-web – JavaSheriff Apr 10 '19 at 19:10

1 Answers1

1

To build a deployable war file into an external container, you have to :

  • Reconfigure your project to produce a WAR
  • Declare the embedded container ( Tomcat ) dependency as provided

    <packaging>war</packaging>
    
    <dependencies>
        ...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        ...
    </dependencies>
    
Djamel Kr
  • 759
  • 1
  • 4
  • 14