title: Gradle spring-boot error - java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
body: <p>Below is my build.gradle file. I am using java 11 and IntelliJ 2019.2.2. As I run the application, I get: <em>Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication</em></p>
  
  <p>As such the error or problem appears to be the same as the one you get when you upgrade from gradle version 2.x to anything 3.4 onwards, but I should not be getting the error with any recent IntelliJ version. I have cleaned the repository, idea cache etc. The main class (com.itreatmd.emr.Application) has only one line  - <em>SpringApplication.run(Application.class, args)</em> and that throws this exception. </p>
  
  <p>Also, when I build the tar file from command line and then explode the tar file, I do not see my jar file packaged under the lib folder of the tar file. I am clearly missing something, presumably something obvious, but just cannot get the handle to it.</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '2.2.1.RELEASE'
      }
      repositories {
          jcenter()
          maven { url "http://repo.spring.io/snapshot" }
          maven { url "http://repo.spring.io/milestone" }
      }
  
      dependencies {
          classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
      }
  }
  
  
  plugins {
      id 'org.springframework.boot' version '2.2.1.RELEASE'
      id 'io.spring.dependency-management' version '1.0.8.RELEASE'
      id 'java'
      id 'application'
      id 'idea'
  }
  mainClassName = 'com.itreatmd.emr.Application'
  group = 'com.itreatmd.emr'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '1.8'
  targetCompatibility = 1.8
  
  repositories {
      mavenCentral()
  }
  
  jar {
      baseName = 'emrServices'
      version = '1.0-SNAPSHOT'
  }
  
  dependencies {
      implementation 'org.springframework.boot:spring-boot-starter-jersey'
      compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
      compile group: 'commons-codec', name: 'commons-codec', version: '1.5'
      compile group: 'commons-io', name: 'commons-io', version: '2.6'
      compile group: 'org.json', name: 'json', version: '20180813'
      compile "org.apache.httpcomponents:httpmime:4.2.3"
      compile group: 'org.yaml', name: 'snakeyaml', version: '1.8'
      compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.1'
      compile group: 'org.springframework', name: 'spring-webmvc', version: '3.1.1.RELEASE'
      testImplementation('org.springframework.boot:spring-boot-starter-test') {
          exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
      }
  }
  
  jar {
      manifest {
          attributes 'Main-Class': 'com.itreatmd.emr.Application',
                  'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' ')
      }
  }
  </code></pre>