{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5724","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5724/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5724/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5724/events","html_url":"https://github.com/spring-projects/spring-boot/issues/5724","id":149145442,"number":5724,"title":"@MockBean does not work for @RefreshScope bean","user":{"login":"colin-shine","id":17406518,"avatar_url":"https://avatars.githubusercontent.com/u/17406518?v=3","gravatar_id":"","url":"https://api.github.com/users/colin-shine","html_url":"https://github.com/colin-shine","followers_url":"https://api.github.com/users/colin-shine/followers","following_url":"https://api.github.com/users/colin-shine/following{/other_user}","gists_url":"https://api.github.com/users/colin-shine/gists{/gist_id}","starred_url":"https://api.github.com/users/colin-shine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colin-shine/subscriptions","organizations_url":"https://api.github.com/users/colin-shine/orgs","repos_url":"https://api.github.com/users/colin-shine/repos","events_url":"https://api.github.com/users/colin-shine/events{/privacy}","received_events_url":"https://api.github.com/users/colin-shine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/62","html_url":"https://github.com/spring-projects/spring-boot/milestones/1.4.0.M3","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/62/labels","id":1608585,"number":62,"title":"1.4.0.M3","description":"Target for Spring I/O Conference","creator":{"login":"philwebb","id":519772,"avatar_url":"https://avatars.githubusercontent.com/u/519772?v=3","gravatar_id":"","url":"https://api.github.com/users/philwebb","html_url":"https://github.com/philwebb","followers_url":"https://api.github.com/users/philwebb/followers","following_url":"https://api.github.com/users/philwebb/following{/other_user}","gists_url":"https://api.github.com/users/philwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/philwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwebb/subscriptions","organizations_url":"https://api.github.com/users/philwebb/orgs","repos_url":"https://api.github.com/users/philwebb/repos","events_url":"https://api.github.com/users/philwebb/events{/privacy}","received_events_url":"https://api.github.com/users/philwebb/received_events","type":"User","site_admin":false},"open_issues":61,"closed_issues":37,"state":"open","created_at":"2016-02-26T18:37:00Z","updated_at":"2016-04-21T23:21:13Z","due_on":"2016-05-12T07:00:00Z","closed_at":null},"comments":4,"created_at":"2016-04-18T13:05:35Z","updated_at":"2016-04-21T23:23:10Z","closed_at":null,"body":"Sample project:\r\nhttps://github.com/colin-shine/mockbean-issue\r\n\r\nRun the `MyTest` to see the problem.\r\n\r\nSpring Boot: `v1.4.0.M2`\r\nSpring Cloud Config: `1.1.0.RC2`\r\n\r\n`@MockBean` detects 2 beans instead of one:\r\n\r\n```\r\njava.lang.IllegalStateException: Unable to register mock bean issues.spring.shine.colin.BeanB expected a single existing bean to replace but found [beanB, scopedTarget.beanB]\r\n\tat org.springframework.boot.test.mock.mockito.MockitoPostProcessor.getBeanName(MockitoPostProcessor.java:218)\r\n\tat org.springframework.boot.test.mock.mockito.MockitoPostProcessor.registerMock(MockitoPostProcessor.java:171)\r\n\tat org.springframework.boot.test.mock.mockito.MockitoPostProcessor.register(MockitoPostProcessor.java:161)\r\n\tat org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:131)\r\n\tat org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:119)\r\n\tat org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)\r\n\tat org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)\r\n\tat org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:680)\r\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:522)\r\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765)\r\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:314)\r\n\tat org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:104)\r\n\tat org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)\r\n\tat org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)\r\n\t... 27 more\r\n```"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/213157106","html_url":"https://github.com/spring-projects/spring-boot/issues/5724#issuecomment-213157106","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5724","id":213157106,"user":{"login":"philwebb","id":519772,"avatar_url":"https://avatars.githubusercontent.com/u/519772?v=3","gravatar_id":"","url":"https://api.github.com/users/philwebb","html_url":"https://github.com/philwebb","followers_url":"https://api.github.com/users/philwebb/followers","following_url":"https://api.github.com/users/philwebb/following{/other_user}","gists_url":"https://api.github.com/users/philwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/philwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwebb/subscriptions","organizations_url":"https://api.github.com/users/philwebb/orgs","repos_url":"https://api.github.com/users/philwebb/repos","events_url":"https://api.github.com/users/philwebb/events{/privacy}","received_events_url":"https://api.github.com/users/philwebb/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T23:23:10Z","updated_at":"2016-04-21T23:23:10Z","body":"The `scopedTarget.` prefix is used by [ScopedProxyUtils](https://github.com/spring-projects/spring-framework/blob/183594207fbb447e1b59262b4469f2aefbb8a3ec/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java#L37) so I think it's safe to just filter those from the candidates."}}