Announcement Announcement Module
Collapse
No announcement yet.
complete lazy-init example Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • complete lazy-init example

    Is it possible to find complete lazy-init example.

    I have following problem. I have lazy initiated bean defined like
    Code:
    <bean id="target" class="example.Target" lazy-init="true">
    </bean> 
           
           
    <bean id="myBean" class="org.springframework.aop.framework.ProxyFactoryBean">
      <property name="targetSource">
        <bean class="org.springframework.aop.target.LazyInitTargetSource">
          <property name="targetBeanName" value="target"/>
        </bean>
      </property>
    </bean>
    
    <bean id="bean2" class="example.TestBean">
      <property name="exampleRef" ref="myBean"/>
    </bean>
    But I've got error during application initialization:
    Code:
    Failed to convert property value of type [$Proxy1] to required type [example.Target] for property 'exampleRef';
    How it is possible to fix it?

  • #2
    To make all beans lazy you can set the "default-lazy-init" property of the enclosing "beans" element to true.

    However, the error would then occur only later. To get rid of it you have to either set the "proxyTargetClass" flag to true on your ProxyFactoryBean or, the recommended way, have your bean implement an interface and use that in accessing code.

    Regards,
    Andreas

    Comment

    Working...
    X