package com.hao.config; import com.alibaba.druid.pool.DruidDataSource; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.sql.DataSource; /** * Created by user on 2016/2/17. */ @Configuration public class DatabaseConfig { @Value("${spring.datasource.url}") private String jdbcUrl; @Value("${spring.datasource.username}") private String jdbcUsername; @Value("${spring.datasource.password}") private String jdbcPassword; @Bean public DataSource dataSource(){ DruidDataSource dataSource = new DruidDataSource(); dataSource.setUrl(jdbcUrl); dataSource.setUsername(jdbcUsername); dataSource.setPassword(jdbcPassword); return dataSource; } }