站在风口哈气 2017-07-24 15:42 采纳率: 14.3%
浏览 2314

spring中的配置文件中的property标签中的ref属性和value属性有什么不同?

请问spring中的配置文件中的property标签中的ref属性和value属性有什么不同?

  • 写回答

2条回答 默认 最新

  • DavisChen_Infinite 2017-07-25 01:19
    关注


    <!-- insert dependencies as required as here -->


    class="org.springframework.aop.framework.ProxyFactoryBean">

    <!-- notice how we refer to the parent bean -->

    <!-- insert other configuration and dependencies as required here -->

    下面是关于ref的说明,ref是Here you set the value of the specified property of a bean to be a reference to another bean (a collaborator) managed by the container
    The ref element is the final element inside a or definition element. Here you set the value of the specified property of a bean to be a reference to another bean (a collaborator) managed by the container. The referenced bean is a dependency of the bean whose property will be set, and it is initialized on demand as needed before the property is set. (If the collaborator is a singleton bean, it may be initialized already by the container.) All references are ultimately a reference to another object. Scoping and validation depend on whether you specify the id/name of the other object through the bean, local, or parent attributes.
    Specifying the target bean through the bean attribute of the tag is the most general form, and allows creation of a reference to any bean in the same container or parent container, regardless of whether it is in the same XML file. The value of the bean attribute may be the same as the id attribute of the target bean, or as one of the values in the name attribute of the target bean.
    而value已办是设定一些固定值的参数,希望对你有所帮助。可以参考下面文档
    http://docs.spring.io/spring/docs/4.3.0.BUILD-SNAPSHOT/spring-framework-reference/htmlsingle/#beans-ref-element

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧