title: @Autowired BeanCreationException with JUnit
body: <p>I know this question has been asked many times but I've been stuck on this for a few days and cannot figure out why this is happening.</p>
  
  <p>Here is my JUnit test suite, and <strong>the issue happens when I try to @Autowire RequestService</strong>:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations = {"classpath:**/*.xml"})
  public class RequestServiceTest {
      @Autowired
      private RequestService requestService;
  
      @Test
      public void add() throws Exception {
          requestService.add(new Request(1, "hello"));
          requestService.add(new Request(2, "hi"));
          Request requestResponseFromDatabase = (Request) requestService.findById(1);
          assertEquals("hello", requestResponseFromDatabase.getRestRequestParameters());
      }
  }
  </code></pre>
  
  <hr>
  
  <p>Below is my code for my model, DAO, and service classes.</p>
  
  <p>Model (leaving out the constructor and other fields for brevity)</p>
  
  <pre><code>@Entity
  public class Request implements Serializable {
  
      @Id
      private Integer restRequestId;
  
      private Timestamp restRequestTimestamp;
  
      private String restRequestParameters;
  }
  </code></pre>
  
  <hr>
  
  <p>DAO</p>
  
  <pre><code>@Component
  public class RequestDAO {
  
      @Autowired
      private RequestService requestService;
  
      @PersistenceContext
      private EntityManager entityManager;
  
      public void persist(Request request) {
          entityManager.persist(request);
      }
  
      public void update(Request request) {
          entityManager.getTransaction().begin();
          entityManager.merge(request);
          entityManager.getTransaction().commit();
      }
  
      public Object findById(Serializable id) {
          Request request = entityManager.find(Request.class, id);
          if (request == null) {
              throw new EntityNotFoundException("Cannot find Request for ID " + id);
          }
          return request;
      }
  
      public void delete(Request request) {
          entityManager.getTransaction().begin();
          entityManager.remove(request);
          entityManager.getTransaction().commit();
      }
  
      public void deleteById(Serializable id) {
          Request request = entityManager.find(Request.class, id);
          if (request == null) {
              throw new EntityNotFoundException("Cannot find Request for ID " + id);
          } else if (request != null) {
              entityManager.getTransaction().begin();
              entityManager.remove(request);
              entityManager.getTransaction().commit();
          }
      }
  
      public List&lt;Request&gt; findAll() {
          Query query = entityManager.createQuery("SELECT e from Request e");
          List&lt;Request&gt; requests = query.getResultList();
          return requests;
      }
  
      public void deleteAll() {
          List&lt;Request&gt; requests = findAll();
          for (Request request : requests) {
              delete(request);
          }
      }
  
  }
  </code></pre>
  
  <hr>
  
  <p>Service</p>
  
  <pre><code>@Component
  public class RequestService {
  
      @Autowired
      private RequestDAO requestDAO;
  
      @Transactional
      public void add(Request request) {
          requestDAO.persist(request);
      }
  
      @Transactional
      public void update(Request request) {
          requestDAO.update(request);
      }
  
      @Transactional
      public Object findById(Serializable id) {
          return requestDAO.findById(id);
      }
  
      @Transactional
      public void delete(Request request) {
          requestDAO.delete(request);
      }
  
      @Transactional
      public void deleteById(Request request) {
          requestDAO.delete(request);
      }
  
      @Transactional
      public void deleteAll() {
          requestDAO.deleteAll();
      }
  
      @Transactional
      public void addAll(Collection&lt;Request&gt; requestCollection) {
          for (Request request : requestCollection) {
              requestDAO.persist(request);
          }
      }
  
      @Transactional(readOnly = true)
      public List&lt;Request&gt; findAll() {
          return requestDAO.findAll();
      }
  }
  </code></pre>
  
  <hr>
  
  <p>spring.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:p="http://www.springframework.org/schema/p"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx.xsd
          "&gt;
  
  
  &lt;!-- Scans the classpath for annotated components that will be auto-registered as Spring beans --&gt;
      &lt;context:component-scan base-package="com.company.mypackage"/&gt;
  
      &lt;!-- Activates scanning of @Autowired --&gt;
      &lt;context:annotation-config/&gt;
  
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="org.hsqldb.jdbcDriver"/&gt;
          &lt;property name="url" value="jdbc:hsqldb:mem://requestDb"/&gt;
          &lt;property name="username" value="user"/&gt;
          &lt;property name="password" value="pass"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
            p:packagesToScan="com.company.mypackage"
            p:dataSource-ref="dataSource"&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
                  &lt;property name="generateDdl" value="true"/&gt;
                  &lt;property name="showSql" value="true"/&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManger" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven transaction-manager="transactionManger"/&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <hr>
  
  <p>Full stacktrace:</p>
  
  <pre><code>May 23, 2016 1:57:38 PM org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
  INFO: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
  May 23, 2016 1:57:38 PM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
  INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
  May 23, 2016 1:57:38 PM org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
  INFO: Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3498ed, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1a407d53, org.springframework.test.context.support.DirtiesContextTestExecutionListener@3d8c7aca, org.springframework.test.context.transaction.TransactionalTestExecutionListener@5ebec15, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@21bcffb5]
  May 23, 2016 1:57:38 PM org.springframework.context.support.GenericApplicationContext prepareRefresh
  INFO: Refreshing org.springframework.context.support.GenericApplicationContext@548b7f67: startup date [Mon May 23 13:57:38 EDT 2016]; root of context hierarchy
  May 23, 2016 1:57:38 PM org.springframework.test.context.TestContextManager prepareTestInstance
  SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1a407d53] to prepare test instance [com.company.mypackage.request.service.RequestServiceTest@57175e74]
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.mypackage.request.service.RequestServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.mypackage.request.service.RequestService com.company.mypackage.request.service.RequestServiceTest.requestService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.mypackage.request.service.RequestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:385)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
      at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:230)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:249)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.mypackage.request.service.RequestService com.company.mypackage.request.service.RequestServiceTest.requestService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.mypackage.request.service.RequestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
      ... 30 more
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.mypackage.request.service.RequestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
      ... 32 more
  
  
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.mypackage.request.service.RequestServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.mypackage.request.service.RequestService com.company.mypackage.request.service.RequestServiceTest.requestService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.mypackage.request.service.RequestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:385)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
      at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:230)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:249)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.mypackage.request.service.RequestService com.company.mypackage.request.service.RequestServiceTest.requestService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.mypackage.request.service.RequestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
      ... 30 more
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.mypackage.request.service.RequestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
      ... 32 more
  
  
  Process finished with exit code -1
  </code></pre>
  
  <hr>
  
  <p>Additional Details</p>
  
  <ul>
  <li>Spring version: 4.2.5.RELEASE</li>
  <li>Hibernate version: 5.1.0.Final</li>
  <li>My spring.xml is located within src/main/resources (yes I am aware that it is not the best practice but wanted to make sure my tests work first. I did try to keep it in my src/test/resources folder but kept getting issues with my ApplicationContext not being able to load)</li>
  </ul>
  
  <p>Resources followed:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/26462926/autowired-with-junit-tests">@Autowired with JUnit tests</a></li>
  <li><a href="https://stackoverflow.com/questions/30821085/autowired-beancreationexception">@AUTOWIRED : BeanCreationException</a></li>
  <li><a href="https://stackoverflow.com/questions/14101715/autowired-fails-with-junit-spring">@Autowired fails with JUnit &amp; Spring</a></li>
  <li><a href="https://stackoverflow.com/questions/17623694/spring-not-autowiring-in-unit-tests-with-junit">Spring not autowiring in unit tests with JUnit</a></li>
  <li><a href="http://www.journaldev.com/7655/spring-orm-example-with-jpa-hibernate-transactions" rel="nofollow noreferrer">Spring ORM example with JPA, Hibernate, Transactions</a></li>
  </ul>
  
  <p>Any ideas on how to resolve this? I have asked similar questions to this in the past and do apologize - having a hard time understanding Spring along with all of it's documentation. I want to make sure I fully understand this to avoid making the same mistake in the future.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> Here is my folder structure:</p>
  
  <p><a href="https://i.stack.imgur.com/cBd0A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cBd0A.png" alt="enter image description here"></a></p>
  
  <p>Stack trace when using <code>@ContextConfiguration(locations = {"classpath:spring.xml"})</code>:</p>
  
  <pre><code>May 23, 2016 3:20:39 PM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
  INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
  May 23, 2016 3:20:39 PM org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
  INFO: Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@60f82f98, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@35f983a6, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7f690630, org.springframework.test.context.transaction.TransactionalTestExecutionListener@edf4efb, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@2f7a2457]
  May 23, 2016 3:20:39 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
  INFO: Loading XML bean definitions from class path resource [spring.xml]
  May 23, 2016 3:20:39 PM org.springframework.context.support.GenericApplicationContext prepareRefresh
  INFO: Refreshing org.springframework.context.support.GenericApplicationContext@174d20a: startup date [Mon May 23 15:20:39 EDT 2016]; root of context hierarchy
  May 23, 2016 3:20:39 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
  INFO: Loaded JDBC driver: org.hsqldb.jdbcDriver
  May 23, 2016 3:20:39 PM org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean createNativeEntityManagerFactory
  INFO: Building JPA container EntityManagerFactory for persistence unit 'default'
  May 23, 2016 3:20:39 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
  INFO: HHH000204: Processing PersistenceUnitInfo [
      name: default
      ...]
  May 23, 2016 3:20:39 PM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {5.1.0.Final}
  May 23, 2016 3:20:39 PM org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: HHH000206: hibernate.properties not found
  May 23, 2016 3:20:39 PM org.hibernate.cfg.Environment buildBytecodeProvider
  INFO: HHH000021: Bytecode provider name : javassist
  May 23, 2016 3:20:39 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager &lt;clinit&gt;
  INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  May 23, 2016 3:20:40 PM org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator initiateService
  WARN: HHH000342: Could not obtain connection to query metadata : User not found: USER
  May 23, 2016 3:20:40 PM org.springframework.context.support.GenericApplicationContext refresh
  WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  May 23, 2016 3:20:40 PM org.springframework.test.context.TestContextManager prepareTestInstance
  SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@35f983a6] to prepare test instance [com.company.mypackage.request.service.RequestServiceTest@481ba2cf]
  java.lang.IllegalStateException: Failed to load ApplicationContext
      at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
      at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
      at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:230)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:249)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
  
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
  
  
  java.lang.IllegalStateException: Failed to load ApplicationContext
  
      at java.lang.reflect.Method.invoke(Method.java:497)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  
  Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  
  Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
  
  
  
  Process finished with exit code -1
  </code></pre>