Created
November 24, 2011 08:55
-
-
Save keesun/1390926 to your computer and use it in GitHub Desktop.
Spring 3.1 Application Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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