content: package springbook;
  
  import javax.sql.DataSource;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.Import;
  import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  import org.springframework.jdbc.datasource.SimpleDriverDataSource;
  import org.springframework.transaction.PlatformTransactionManager;
  import org.springframework.transaction.annotation.EnableTransactionManagement;
  
  import com.mysql.jdbc.Driver;
  
  @Configuration
  @EnableTransactionManagement
  @ComponentScan(basePackages="springbook.user")
  @Import(SqlServiceContext.class)
  public class AppContext {
  	@Bean
  	public DataSource dataSource() {
  		SimpleDriverDataSource ds = new SimpleDriverDataSource();
  		ds.setDriverClass(Driver.class);
  		ds.setUrl("jdbc:mysql://localhost/springbook?characterEncoding=UTF-8");
  		ds.setUsername("spring");
  		ds.setPassword("book");
  		return ds;
  	}
  	
  	@Bean
  	public PlatformTransactionManager transactionManager() {
  		DataSourceTransactionManager tm = new DataSourceTransactionManager();
  		tm.setDataSource(dataSource());
  		return tm;
  	}
  }
  