title: maven build failing when generating war package for spring boot application?
body: <p>This is an extension to my previous question <a href="https://stackoverflow.com/questions/29782148/why-do-i-need-main-method-if-i-develop-web-app-as-war-using-spring-boot">here</a> at SO. As per this post, main method is NOT required to generate a <code>deployable war</code></p>
  
  <p>I am trying to generate a <code>deployable war</code> for this simple application of <a href="https://spring.io/guides/gs/uploading-files/" rel="nofollow noreferrer">uploading files</a>. The source code can be for this example application can be found <a href="https://github.com/spring-guides/gs-uploading-files/tree/master/complete" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Following the instructions from spring boot for jar to war conversion, I changed my <code>pom.xml</code> to reflect the following. (Just added <code>tomcat</code> dependency with scope <code>provided</code>).</p>
  
  <p>Reference: <a href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging" rel="nofollow noreferrer">http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging</a></p>
  
  <pre><code>      &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;gs-uploading-files&lt;/artifactId&gt;
      &lt;version&gt;0.1.0&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.2.3.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.7&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Then I changed <code>Application.java</code> as follows</p>
  
  <p>Reference: <a href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file" rel="nofollow noreferrer">http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file</a></p>
  
  <pre><code>@SpringBootApplication
  public class Application extends SpringBootServletInitializer{
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(Application.class);
      }
  
      /*public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      } */
  } 
  </code></pre>
  
  <p>I tried two scenarios. both fail with the following error (<code>Unable to find main class</code>).</p>
  
  <ol>
  <li>No main method (NOTE I have commented out main method above)</li>
  <li>No application.Java file (commented out everything from this file - not shown here)</li>
  </ol>
  
  <p>Error:</p>
  
  <pre><code>[INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 9.218s
  [INFO] Finished at: Thu Apr 23 11:46:24 PDT 2015
  [INFO] Final Memory: 22M/222M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage (default) on project gs-uploading-files: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage failed: Unable to find main class -&gt; [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
  </code></pre>
  
  <p><strong>PS: when I have main method intact, the build is successful</strong></p>