title: SpringBoot: Running application using Maven "mvn clean compile exec:java" works fine but creating jar using "mvn clean install" throws error
body: <p>I am getting the below exception which I try to run my spring boot application using <code>"java -jar jarname.jar"</code> command.</p>
  
  <p>When I run the application using "<strong>mvn clean compile exec:java</strong>" it runs without any exceptions but after creating the jar using "<strong>mvn clean compile -DskipTests install</strong>" command below exception is thrown.</p>
  
  <p>I also noticed a strange behavior, when I update project from my <strong>STS</strong> and then if I create the jar it runs perfectly fine. </p>
  
  <pre><code>ERROR org.springframework.boot.SpringApplication - Application run failed
  org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tenantTransactionManager' defined in class path 
  resource [com/ps/main/TenantDatabaseConfig.class]: Unsatisfied dependency expressed through method 'transactionManager' parameter 0; nested exception is 
  org.springframework.beans.factory.**NoSuchBeanDefinitionException**: No qualifying bean of type 'javax.persistence.EntityManagerFactory' available: expected at least 
  1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value="tenantEntityManagerFactory")}
          at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798)
   ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539) 
  ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
          at com.ps.main.Application.main(Application.java:22) [classes!/:0.0.1-SNAPSHOT]
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
          at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [deliziahr-authentication-service-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [deliziahr-authentication-service-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [deliziahr-authentication-service-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
          at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [deliziahr-authentication-service-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
  **Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManagerFactory'**
   available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value="tenantEntityManagerFactory")}
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1695)
   ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1253) 
  ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
   ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
          ... 27 more
  </code></pre>