<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=shaug" rel="nofollow">Scott Haug</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1136?redirect=false" rel="nofollow">SPR-1136</a></strong> and commented</p>
<p dir="auto">When setting a property with a factory-bean/factory-method -enabled inner bean, I'm prevented from keeping the bean anonymous. Consider the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  &lt;bean id=&quot;foo1&quot; class=&quot;example.Foo&quot;&gt;
    &lt;property name=&quot;bar&quot; value=&quot;baz&quot;/&gt;
  &lt;/bean&gt;

  &lt;bean id=&quot;foo2&quot; class=&quot;example.Foo&quot;&gt;
    &lt;property name=&quot;bar&quot;&gt;
      &lt;bean factory-bean=&quot;foo1&quot; factory-method=&quot;getBar&quot;/&gt;
    &lt;/property&gt;
  &lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">  &lt;bean id="foo1" class="example.Foo"&gt;
    &lt;property name="bar" value="baz"/&gt;
  &lt;/bean&gt;

  &lt;bean id="foo2" class="example.Foo"&gt;
    &lt;property name="bar"&gt;
      &lt;bean factory-bean="foo1" factory-method="getBar"/&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
</code></pre></div>
<p dir="auto">Loading this config results in the following exception:</p>
<p dir="auto">org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name '' defined in ServletContext resource [config.xml]: Unnamed bean definition specifies neither 'class' nor 'parent' - can't generate name<br>
at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.generateBeanName(BeanDefinitionReaderUtils.java:102)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitionElement(DefaultXmlBeanDefinitionParser.java:331)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parsePropertySubElement(DefaultXmlBeanDefinitionParser.java:660)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parsePropertyValue(DefaultXmlBeanDefinitionParser.java:650)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parsePropertyElement(DefaultXmlBeanDefinitionParser.java:593)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parsePropertyElements(DefaultXmlBeanDefinitionParser.java:492)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitionElement(DefaultXmlBeanDefinitionParser.java:360)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitionElement(DefaultXmlBeanDefinitionParser.java:328)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitions(DefaultXmlBeanDefinitionParser.java:265)<br>
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(DefaultXmlBeanDefinitionParser.java:185)<br>
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:238)<br>
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:155)<br>
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:99)<br>
...</p>
<p dir="auto">Giving the inner bean an id is a sufficient workaround for the issue, but obviously it would be nice if this wasn't necessary.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.2.2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398059224" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/5911" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/5911/hovercard" href="https://github.com/spring-projects/spring-framework/issues/5911">#5911</a> anonymous inner bean without class and parent attributes fails to load (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=david_syer" rel="nofollow">Dave Syer</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4738?redirect=false" rel="nofollow">SPR-4738</a></strong> and commented</p>
<p dir="auto">Scan classpath for persistence annotations when creating session factory for hibernate.  The AnnotationSessionFactoryBean requires me to explictly enumerate all classes that are annotated, whereas I know Spring could discover that for me, e.g.:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean id=&quot;sessionFactory&quot;
	class=&quot;org...AutoDiscoverAnnotationSessionFactoryBean&quot;&gt;
	&lt;property name=&quot;basePackage&quot;
		value=&quot;com.springsource.consulting.integration&quot; /&gt;
	&lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
            ...
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;bean id="sessionFactory"
	class="org...AutoDiscoverAnnotationSessionFactoryBean"&gt;
	&lt;property name="basePackage"
		value="com.springsource.consulting.integration" /&gt;
	&lt;property name="dataSource" ref="dataSource" /&gt;
            ...
&lt;/bean&gt;
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.3</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398060296" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/6038" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/6038/hovercard" href="https://github.com/spring-projects/spring-framework/issues/6038">#6038</a> Auto-pickup of entity beans (<em><strong>"duplicates"</strong></em>)</li>
</ul>