package com.ffii.fhsmsc.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.ffii.core.support.JdbcDao;

/** @author Terence */
@Configuration
@ComponentScan(basePackages = { "com.ffii.core.*","com.ffii.fhsmsc.*"})
@EnableScheduling
@EnableAsync
public class AppConfig {

	@Bean
	@ConfigurationProperties(prefix = "spring.datasource")
	public DataSource dataSource() {
		return DataSourceBuilder.create().build();
	}

	@Bean
	public JdbcDao jdbcDao(DataSource dataSource) {
		return new JdbcDao(dataSource);
	}
	
}
