开发者社区 问答 正文

_spring_ioc通过工厂方法来创建对象中的静态工厂,如何用代码实现呀?

已解决

_spring_ioc通过工厂方法来创建对象中的静态工厂,如何用代码实现呀?

展开
收起
游客xaiaywggqg622 2022-03-31 17:21:47 521 分享 版权
2 条回答
写回答
取消 提交回答
  • 推荐回答

    UserFactorv.java:

    public class UserFactory {

    public static User newInstance (String name) {

    return new User (name);

    }

    }

    bean.xml 配置:

    y. UserFactory"

    factory- method= "newInstance">

    2022-03-31 17:22:52
    赞同 展开评论
  • UserFactorv.java:

    public class UserFactory {

    public static User newInstance (String name) {

    return new User (name);

    }

    }

    bean.xml 配置:

    y. UserFactory"

    factory- method= "newInstance">

    2022-03-31 17:22:52
    赞同 展开评论
问答地址: