title: How do you autowire/inject your datasource in Spring-boot?
body: <p>I have been working with Spring boot for a bit now, and the datasource is always configured in your application.properties in every example I have seen, kind of like this:</p>
  
  <pre><code># DataSource configuration
  spring.datasource.driver-class-name=org.postgresql.Driver
  spring.datasource.url=jdbc:postgresql://localhost:5432/abcdef
  spring.datasource.username=******
  spring.datasource.password=******
  </code></pre>
  
  <p>However, lately I have been trying to integrate Spring Social, and the examples I have seen configure it in java in a config file like this:</p>
  
  <pre><code>@Bean
  public DataSource dataSource() {
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName(env.getProperty("db.driver"));
      dataSource.setUrl(env.getProperty("db.url"));
      dataSource.setUsername(env.getProperty("db.username"));
      dataSource.setPassword(env.getProperty("db.password"));
      return dataSource;
  }
  </code></pre>
  
  <p>This allows for the datasource object to later be injected or autowired into the social config as seen <a href="https://github.com/pkainulainen/spring-social-examples/blob/master/sign-in/spring-mvc-normal/src/main/java/net/petrikainulainen/spring/social/signinmvc/config/SocialContext.java" rel="noreferrer">here</a> for example.</p>
  
  <p>My question is, do I need to configure a datasource bean like this to be able to later inject the datasource, or will Spring-boot handle that for me?</p>