Skip to content

Instantly share code, notes, and snippets.

@Qkyrie
Created December 5, 2013 10:32
Show Gist options
  • Save Qkyrie/7803240 to your computer and use it in GitHub Desktop.
Save Qkyrie/7803240 to your computer and use it in GitHub Desktop.
@bean with destroy and init methods
public class Foo {
public void init() {
// initialization logic
}
}
public class Bar {
public void cleanup() {
// destruction logic
}
}
@Configuration
public class AppConfig {
@Bean(initMethod = "init")
public Foo foo() {
return new Foo();
}
@Bean(destroyMethod = "cleanup")
public Bar bar() {
return new Bar();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment