Created
May 11, 2014 06:43
-
-
Save jnizet/c7c393072d3af65a9e02 to your computer and use it in GitHub Desktop.
Setter injection
This file contains hidden or 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
public class Bar { | |
} | |
public class Foo { | |
@Autowired | |
public void setBar(Bar bar) { | |
System.out.println("setBar() was called"); | |
} | |
} | |
@Configuration | |
public class AppConfig { | |
@Bean | |
public Foo foo() { | |
return new Foo(); | |
} | |
@Bean | |
public Bar bar() { | |
return new Bar(); | |
} | |
} | |
public class Main { | |
public static void main(String[] args) { | |
new AnnotationConfigApplicationContext(AppConfig.class).getBean(Foo.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment