From 320a6b784f7360fe12f308037e1d09da43a19962 Mon Sep 17 00:00:00 2001 From: xuchengsheng Date: Wed, 18 Oct 2023 20:41:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ApplicationContextAware?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spring-aware/spring-aware-applicationContextAware/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-aware/spring-aware-applicationContextAware/README.md b/spring-aware/spring-aware-applicationContextAware/README.md index 08e9a2b..6fbd8f6 100644 --- a/spring-aware/spring-aware-applicationContextAware/README.md +++ b/spring-aware/spring-aware-applicationContextAware/README.md @@ -96,15 +96,13 @@ public interface ApplicationContextAware extends Aware { ### 五、最佳实践 -首先来看看启动类入口,上下文环境使用`AnnotationConfigApplicationContext`(此类是使用Java注解来配置Spring容器的方式),构造参数我们给定了一个`MyConfiguration`组件类。然后从Spring上下文中获取一个`MyApplicationContextAware`类型的bean,最后调用`publish`方法用于发布一个事件。 +首先来看看启动类入口,上下文环境使用`AnnotationConfigApplicationContext`(此类是使用Java注解来配置Spring容器的方式),构造参数我们给定了一个`MyConfiguration`组件类。 ```java public class ApplicationContextAwareApplication { public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfiguration.class); - MyApplicationContextAware contextAware = context.getBean(MyApplicationContextAware.class); - contextAware.publish("hello world"); } } ```