<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=andypiper" rel="nofollow">Andy Piper</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2533?redirect=false" rel="nofollow">SPR-2533</a></strong> and commented</p>
<p dir="auto">JavaBeans support the management of listeners via the addX() methods (see section 6 of the JavaBeans specification, titled "Events"). It would be extremely useful to support this in spring so that event listeners could be added to a bean using standard IoC. This could be done either by overloading the meaning of "property" or introducing a new "listener" tag. For instance given the addX() method on a bean you would like to be able to do the following:</p>
<p dir="auto">&lt;bean id="eventBean"&gt;<br>
&lt;property name="X" ref="listener1"/&gt;<br>
&lt;property name="X" ref="listener2"/&gt;<br>
&lt;/bean&gt;<br>
&lt;bean id="listener1/&gt;<br>
&lt;bean id="listener2/&gt;</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 RC3</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="398050219" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/4961" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/4961/hovercard" href="https://github.com/spring-projects/spring-framework/issues/4961">#4961</a> Please improve BeanFactory support for containers &amp; collections (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto">4 votes, 3 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=nurkiewicz" rel="nofollow">Tomasz Nurkiewicz</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8808?redirect=false" rel="nofollow">SPR-8808</a></strong> and commented</p>
<p dir="auto">I am using <code class="notranslate">AnnotationConfigWebApplicationContext</code> and XML-free testing support with <code class="notranslate">@ContextConfiguration(classes=...)</code>. When pointed <code class="notranslate">@Configuration</code> class contains <code class="notranslate">@ComponentScan</code> with a package containing that class:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="package com.example.foo;

@Configuration
@ComponentScan(basePackages = &quot;com.example.foo&quot;)
public class Config { }"><pre class="notranslate"><span class="pl-k">package</span> <span class="pl-s1">com</span>.<span class="pl-s1">example</span>.<span class="pl-s1">foo</span>;

<span class="pl-c1">@</span><span class="pl-c1">Configuration</span>
<span class="pl-c1">@</span><span class="pl-c1">ComponentScan</span>(<span class="pl-s1">basePackages</span> = <span class="pl-s">"com.example.foo"</span>)
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">Config</span> { }</pre></div>
<p dir="auto">I get unexpected exception:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'config' for bean class [com.example.foo.Config] conflicts with existing, non-compatible bean definition of same name and class [com.example.foo.Config]"><pre class="notranslate"><code class="notranslate">org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'config' for bean class [com.example.foo.Config] conflicts with existing, non-compatible bean definition of same name and class [com.example.foo.Config]
</code></pre></div>
<p dir="auto">While I understand why it happens, IMHO Spring should handle this case and simply ignore <code class="notranslate">@Configuration</code> found in scanned package if it has already been provided in <code class="notranslate">AnnotationConfigWebApplicationContext</code>.</p>
<p dir="auto">Test case attached. On branch <code class="notranslate">master</code> you'll find a test case failing, branch <code class="notranslate">fix</code> fixes the problem by simply <code class="notranslate">@Config</code> to another package.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 RC1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/19027/testcase2.zip" rel="nofollow">testcase2.zip</a> (<em>25.13 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/19101/testcase3.zip" rel="nofollow">testcase3.zip</a> (<em>29.18 kB</em>)</li>
</ul>
<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="398115777" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13521" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13521/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13521">#13521</a> Default <code class="notranslate">@ComponentScan</code>'s exclude filter to exclude <code class="notranslate">@Configuration</code> annotated classes (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398112157" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12956" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12956/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12956">#12956</a> Allow recursive use of <code class="notranslate">@ComponentScan</code></li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/ca4eafd4dda3877d5bcce03c6d5aa98edded1375/hovercard" href="https://github.com/spring-projects/spring-framework/commit/ca4eafd4dda3877d5bcce03c6d5aa98edded1375"><tt>ca4eafd</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/6991cd9cdf610f94ace3cd8072634106830b439f/hovercard" href="https://github.com/spring-projects/spring-framework/commit/6991cd9cdf610f94ace3cd8072634106830b439f"><tt>6991cd9</tt></a></p>