Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created April 28, 2020 06:46
Show Gist options
  • Save CheolhoJeon/5fab3e8229250fad1bd425b65a6c0ddd to your computer and use it in GitHub Desktop.
Save CheolhoJeon/5fab3e8229250fad1bd425b65a6c0ddd to your computer and use it in GitHub Desktop.
@Configuration
public class MemberConfigWithProfile {
@Autowired
private DataSource dataSource;
@Bean
public MemberDao memberDao() {
return new MemberDao(dataSource);
}
@Configuration
@Profile("dev")
public static class DsDevConfig {
@Bean(destroyMethod = "close")
public DataSource dataSource() {
...
}
}
@Configuration
@Profile("real")
public static class DsRealConfig {
@Bean(destroyMethod = "close")
public DataSource dataSource() {
...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment