1:如果static方法
  public static UserService creatUserServiceimpl() {
        return new UserServiceimpl();
    }
<bean ></bean>

2:非静态方法创建实例
  public UserService creatUserServiceimpl() {
        return new UserServiceimpl();
    }
<bean ></bean>
<bean >
    

ApplicationContext accContext = new ClassPathXmlApplicationContext("com/bj/jiekou/beans.xml");
        UserService bean2 = (UserService)accContext.getBean("userFactory");
        bean2.saveUser();

 

相关文章:

  • 2021-08-20
  • 2021-05-24
  • 2021-09-14
  • 2022-01-21
  • 2021-08-16
  • 2021-11-06
  • 2022-12-23
猜你喜欢
  • 2021-09-16
  • 2022-01-21
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
相关资源
相似解决方案