站在风口哈气 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

    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错