BeanNameAware test the result
This commit is contained in:
parent
4b91a76d8f
commit
5dc1b18c29
@ -1,5 +1,7 @@
|
|||||||
package com.baeldung.aware;
|
package com.baeldung.aware;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gebruiker on 4/24/2018.
|
* Created by Gebruiker on 4/24/2018.
|
||||||
*/
|
*/
|
||||||
@ -7,5 +9,9 @@ public class AwareExample {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
AnnotationConfigApplicationContext context
|
||||||
|
= new AnnotationConfigApplicationContext(Config.class);
|
||||||
|
|
||||||
|
MyBeanName myBeanName = context.getBean(MyBeanName.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
package com.baeldung.aware;
|
package com.baeldung.aware;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
|
@Bean(name = "myCustomBeanName")
|
||||||
|
public MyBeanName getMyBeanName() {
|
||||||
|
return new MyBeanName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,4 +17,6 @@ public class MyBeanFactory implements BeanFactoryAware {
|
|||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
System.out.println(beanFactory);
|
System.out.println(beanFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,6 @@ package com.baeldung.aware;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.BeanNameAware;
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Gebruiker on 4/25/2018.
|
|
||||||
*/
|
|
||||||
public class MyBeanName implements BeanNameAware {
|
public class MyBeanName implements BeanNameAware {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user