bean examples
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package org.baeldung.di.core;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanA {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("beanB2")
|
||||
private IBeanB dependency;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.baeldung.di.core;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanB implements IBeanB {
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.baeldung.di.core;
|
||||
|
||||
public interface IBeanB {
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.baeldung.di.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.di")
|
||||
public class ContextWithJavaConfig {
|
||||
|
||||
public ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user