title: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication with maven-jar-plugin
body: <p>I'm new to Spring and Maven.
  I'm trying to run the jar of a simple application but I'm receiving the following error:</p>
  
  <pre><code>java -jar target/gs-rest-service-0.0.1-SNAPSHOT.jar 
  Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
      at hello.Application.main(Application.java:10)
  Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 1 more
  </code></pre>
  
  <p>This is the pom.xml:</p>
  
  <pre><code>&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;gs-rest-service&lt;/groupId&gt;
    &lt;artifactId&gt;gs-rest-service&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;MyApp&lt;/name&gt;
    &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.4&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;mainClass&gt;hello.Application&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;4.3.10.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot&lt;/artifactId&gt;
          &lt;version&gt;1.5.5.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-autoconfigure&lt;/artifactId&gt;
          &lt;version&gt;1.5.5.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>And this is the main class where SpringApplication is required:</p>
  
  <pre><code>package hello;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>Also I can see that the org.springframework.boot.SpringApplication is located exatly where it should be, within the Maven Dependencies library.
  So I'm not really sure what is going on which is causing this error.</p>
  
  <p>Any idea?</p>