package com.salmon.scommerce.config;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

@Configuration
@PropertySource("classpath:/com/salmon/properties/database.properties")
public class DataSourceConfig {
	
	private Logger LOG = LoggerFactory.getLogger(this.getClass()); 
	
	@Inject
	Environment evn;
	
	@Bean
	public DriverManagerDataSource dataSource() {
		
		LOG.debug("driver is :" + evn.getProperty("mysql.driver"));
		
		DriverManagerDataSource dataSource = new DriverManagerDataSource();
		dataSource.setDriverClassName(evn.getProperty("mysql.driver"));
		dataSource.setUrl(evn.getProperty("mysql.url"));
		dataSource.setUsername(evn.getProperty("mysql.username"));
		dataSource.setPassword(evn.getProperty("mysql.password"));
		
		return dataSource;
	}
}

@@ -127,68 +127,8 @@
 y;%0D%0A
-import org.springframework.beans.factory.annotation.Value;%0D%0A
 impo
@@ -351,16 +351,90 @@
 nment;%0D%0A
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;%0D%0A
 import o
@@ -1193,11 +1193,136 @@
 e;%0D%0A%09%7D%0D%0A
+%09%0D%0A%09@Bean%0D%0A%09public DataSourceTransactionManager txManager() %7B%0D%0A%09%09return new DataSourceTransactionManager(dataSource());%0D%0A%09%7D%0D%0A
 %7D%0D%0A

add transaction manager