ApplicationContext app = newまず、ApplicationContextインスタンスを作成します。これは同じですが、よく見ると使っているクラスが違っていますね。今回は「AnnotationConfigApplicationContext」というクラスのインスタンスを作成しています。
AnnotationConfigApplicationContext(SampleBeanConfig.class);
SampleBeanInterface bean1 =
(SampleBeanInterface)app.getBean(SampleBeanInterface.class);
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
package com.tuyano.libro; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class App { public static void main(String[] args) { ApplicationContext app = new AnnotationConfigApplicationContext(SampleBeanConfig.class); SampleBeanInterface bean1 = (SampleBeanInterface)app.getBean(SampleBeanInterface.class); System.out.println(bean1); } }
<< 前へ | 次へ >> |