JAVA-959: Migrate spring-di to com.baeldung

This commit is contained in:
Krzysiek
2020-03-11 21:09:04 +01:00
parent 5a9ac3ce57
commit 6906bb047d
9 changed files with 50 additions and 50 deletions
@@ -0,0 +1,23 @@
package com.baeldung.store;
import org.springframework.context.annotation.Bean;
public class AppConfig {
@Bean
public Item item1() {
return new ItemImpl1();
}
@Bean
public Store storeThroughConstructorInjection() {
return new Store(item1());
}
@Bean
public Store storeThroughSetterInjection() {
Store store = new Store();
store.setItem(item1());
return store;
}
}
@@ -0,0 +1,5 @@
package com.baeldung.store;
public interface Item {
}
@@ -0,0 +1,5 @@
package com.baeldung.store;
public class ItemImpl1 implements Item {
}
@@ -0,0 +1,23 @@
package com.baeldung.store;
import org.springframework.beans.factory.annotation.Autowired;
public class Store {
@Autowired
private Item item;
public Store() {}
public Store(Item item) {
this.item = item;
}
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
}