title: Spring Boot Jar created. Runs but fails `DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class` IntelliJ
body: <p><br></p>
  
  <p><b>The question has been edited, look ahead for the Updated sections and all the different ways I approached it in order to find a solution.</b></p>
  
  <p><br></p>
  
  <p><b>Initial question</b></p>
  
  <p>I tried to create an executable jar file for my project but I run to the error when trying to run it <code>no main manifest attribute, in kerkinibackend.jar</code>.</p>
  
  <p>The project is a Spring Boot application and I am using IntelliJ as an IDE.</p>
  
  <p>I tried to find the most common scenarios when this could happen from similar questions but I couldn't make it work any way.</p>
  
  <p>The steps I took were :</p>
  
  <ol>
  <li>Opened IntelliJ.</li>
  <li>Opened the project's Structure on the top right icon.</li>
  <li>Navigated to the Artifact.</li>
  <li>Pressed the plus to add new artifact.</li>
  <li>JAR -> from modules with dependencies. (also tried it using the blank option while having a MANIFEST.MF file, which was automatically generated from the first time I tried it).</li>
  <li>Opened the folder for the Main class in the pop-up dialog and specified it.
  (also tried leaving the Main class empty as I read somewhere and left it connect 
  with it through the Manifest).</li>
  <li>Left the rest as default. (this way IntelliJ also creates the needed Manifest, in case you have it already deleting the file will allow to generate it again)</li>
  <li>Then, I pressed Build -> Build Artifacts -> Build.</li>
  <li>The is created with a size of 57Mbs. I tried running it as an executable but I saw it wasn't working. Then I opened the cmd and ran <code>java -jar kerkinibackend.jar</code> and then the error message comes out. The thing is that the <code>MANIFEST.MF</code> file is actually getting created in <code>src/main/java/META-INF</code></li>
  </ol>
  
  <pre><code>Manifest-Version: 1.0
  Main-Class: com.teicm.kerkinibackend.KerkinibackendApplication
  
  </code></pre>
  
  <p>I also do have the needed dependency in pom.xml</p>
  
  <pre><code>    &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;
  </code></pre>
  
  <p><br><br><br><br></p>
  
  <p><b>UPDATE</b></p>
  
  <p>I fixed the problem by changing the default generation of the manifest to be in the resources instead.</p>
  
  <p>Now it the Jar runs but then I get and error from Spring <code>No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.</code></p>
  
  <p><br><br><br><br></p>
  
  <p><br><br><br><br></p>
  
  <p><b>Farther UPDATE</b></p>
  
  <p>I tried to add an extra file the <code>spring.factories</code> (as a read in another answer <a href="https://stackoverflow.com/questions/38792031/springboot-making-jar-files-no-auto-configuration-classes-found-in-meta-inf">Relevant question-answer</a>) inside the META-INF folder in the resource folder in order to fix the previous problem. Now it didn't show the same error but a different one </p>
  
  <pre><code>00:24:26.230 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
  org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
          at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:767)
          at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:218)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1308)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1154)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:391)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
          at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:853)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
          at com.teicm.kerkinibackend.KerkinibackendApplication.main(KerkinibackendApplication.java:11)
  </code></pre>
  
  <p>But I don't know if this brings me a step closer or a step farther. And why wouldn't the MySQL data source be recognized. When I use the project locally everything works, it connects to MySQL, it has communication with the front end.</p>
  
  <p><br><br><br><br></p>
  
  <p><b>Trying a different build method using <code>maven-assembly-plugin</code></b></p>
  
  <p>I also tried using a different way to build the executable jar, through <code>@Zsolt Tolvary</code>s approach (you can find more about it at <a href="https://stackoverflow.com/questions/1082580/how-to-build-jars-from-intellij-properly/45303637#45303637">link</a>). This approach uses in the pom.xml another plugin called <code>maven-assembly-plugin</code>.</p>
  
  <p>Unfortunately doing the suggested steps does generate a jar file but when I try to run the generated jar that exists now in the <code>/target</code> folder, then I get an error message of <code>Error: Could not find or load main class com.teicm.kerkinibackend.KerkinibackendApplication</code> having changed of course in the plugin the name of the Main class :</p>
  
  <pre><code>&lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                      &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;finalName&gt;KerkiniBackEnd&lt;/finalName&gt;
                      &lt;appendAssemblyId&gt;false&lt;/appendAssemblyId&gt;
                      &lt;archive&gt;
                          &lt;manifest&gt;
                              &lt;mainClass&gt;com.teicm.kerkinibackend.KerkinibackendApplication&lt;/mainClass&gt;
                          &lt;/manifest&gt;
                      &lt;/archive&gt;
                      &lt;descriptorRefs&gt;
                          &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                      &lt;/descriptorRefs&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.8&lt;/source&gt;
                      &lt;target&gt;1.8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p><br><br><br><br></p>
  
  <p>For anyone having some spare time feel free to suggest me a solution or even try it him-her self. I really need to generate it, it's the last part of finishing my thesis...</p>
  
  <p>The link for the Github repository is <a href="https://github.com/alexgil1994/kerkinibackend" rel="nofollow noreferrer">Github Repository</a></p>
  
  <p>Thank you for your time and effort</p>