using registerShutdownHook() in the Spring Framework

后端 未结 6 2392
深忆病人
深忆病人 2021-02-08 22:14

I am following this tutorial online to the letter. http://www.tutorialspoint.com/spring/spring_bean_life_cycle.htm

But I get the errors when using Eclipse when I get to

6条回答
  •  再見小時候
    2021-02-08 22:43

    For the error it seems that context is a object of ApplicationContext, whereas in tutorial it should be an object of AbstractApplicationContext

    I am just guessing that you wrote this

    public class MainApp {
       public static void main(String[] args) {
    
          ApplicationContext context = 
                              new ClassPathXmlApplicationContext("Beans.xml");//error here
    
          HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
          obj.getMessage();
          context.registerShutdownHook();
       }
    }
    

提交回复
热议问题