title: Injection of autowired dependencies failed in springboot application
body: <p>I want to start my Spring Boot application with an embedded Tomcat and create the database at runtime.</p>
  
  <p>I wrote the following application.properties file:</p>
  
  <pre><code>server.port=1111
  spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
  spring.jpa.hibernate.ddl-auto=update
  spring.datasource.driverClassName=com.mysql.jdbc.Driver
  spring.datasource.url=jdbc:mysql://localhost:3306/spring-boot
  spring.datasource.username=root
  spring.datasource.password=
  </code></pre>
  
  <p>This is my main class:</p>
  
  <pre class="lang-java prettyprint-override"><code>import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @Configuration
  @EnableAutoConfiguration
  @ComponentScan("ma.mahmoud.springboot")
  public class Application {
      public static void main(String[] args) throws Exception {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>For the DAO I use Spring Data, so I created the following interface:</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface PlaceRepository extends CrudRepository&lt;Place, Long&gt; {
  
  Place findByShortName(String shortName);
  }
  </code></pre>
  
  <p>This is the interface I wrote for my service:</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface PlaceService {
      Place getPlaceByShortName(String shortName);
  }
  </code></pre>
  
  <p>And the implementation of this service is like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Service
  public class PlaceServiceImpl implements PlaceService {
  
      @Autowired
      private PlaceRepository placeRepository;
  
  
      public Place getPlaceByShortName(String shortName) {
          return placeRepository.findByShortName(shortName);
      }
  
      // GETTERS AND SETTERS 
  }
  </code></pre>
  
  <p>Initially, my application was throwing the following error on startup:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'placeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ma.mahmoud.springboot.repository.PlaceRepository ma.mahmoud.springboot.service.impl.PlaceServiceImpl.placeRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ma.mahmoud.springboot.repository.PlaceRepository] 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)}
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>However, after replacing the annotations on my main class by <code>@SpringBootApplication</code> and by correcting the <code>spring.jpa.database-platform</code> to <code>org.hibernate.dialect.MySQL5Dialect</code>, I got the following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.support.DefaultConversionService.addCollectionConverters(Lorg/springframework/core/convert/converter/ConverterRegistry;)V from class org.springframework.boot.bind.RelaxedConversionService
  </code></pre>
  
  <p>I'm using the following pom.xml:</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.4.3.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;hibernate.version&gt;5.0.3.Final&lt;/hibernate.version&gt;
      &lt;spring.version&gt;4.2.2.RELEASE&lt;/spring.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
          &lt;artifactId&gt;commons-collections4&lt;/artifactId&gt;
          &lt;version&gt;4.0&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>I'm not using any XML configuration for Spring since I use annotations. Did I forget something? Or do I need another annotation to make it work?</p>