Skip to content

Instantly share code, notes, and snippets.

@keesun
Created November 24, 2011 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keesun/1390926 to your computer and use it in GitHub Desktop.
Save keesun/1390926 to your computer and use it in GitHub Desktop.
Spring 3.1 Application Configuration
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = "whiteship", excludeFilters = {@ComponentScan.Filter(Configuration.class), @ComponentScan.Filter(Controller.class)})
public class AppConfig {
@Bean(destroyMethod = "shutdown")
public DataSource dataSource(){
return new EmbeddedDatabaseBuilder()
.setName("bookDB")
.setType(EmbeddedDatabaseType.H2)
.addScript("classpath:book-schema.sql")
.build();
}
@Bean
public JdbcTemplate jdbcTemplate(){
return new JdbcTemplate(dataSource());
}
@Bean
public PlatformTransactionManager transactionManager(){
return new DataSourceTransactionManager(dataSource());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment