Announcement Announcement Module
Collapse
No announcement yet.
Configuration with autowired dependency not finding beans in a profiled configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuration with autowired dependency not finding beans in a profiled configuration

    I have the following set up:

    Configuration A (no profile) with an autowrited dependency of a bean B

    Configuration C (profile TEST) with bean B

    Configuration D (profile LIVE) with bean B

    A includes B as a field and it's autowired.

    I have a test case like so

    Code:
    @ActiveProfiles("TEST")
    @ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = {A.class,C.class})
    public class BatchImportTest {
    
    	@Test
    	public void testImport() throws Exception {
    
               // do whatever
    	}
    }

    When it runs it failed as B cannot be autowired to A. If I remove @Profile("TEST") from B it all works.

    Why is this ? Surely B should be created as the run time profile is TEST, and then B gets wired into A.
Working...
X