I have an integration test with the following configuration:
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("integration-test")
@ContextConfiguration(classes = { PersistenceJpaConfig.class, ContextConfig.class, ServiceConfig.class, WebConfig.class})
@WebAppConfiguration
public class LeadsIntegrationTest {
...
}
The PersistenceJpaConfig class is the following:
@Configuration
@EnableTransactionManagement
@ComponentScan({ "org.persistence", "org.common.persistence" })
@PropertySource({ "persistence-${spring.profiles.active}.properties" })
@EnableJpaRepositories(basePackages = org.persistence.dao")
public class PersistenceJpaConfig {
...
}
The ${spring.profiles.active} resolves fine when the active profile is "dev", but when set to "integration-test" in the @ActiveProfiles("integration-test), it fails to resolve. Both the persistence-dev.properties and persistence-integration-test.properties are located in src/main/resources . The properties for dev has mysql configuration, and the integration-test has h2 embedded configuraiton for running integration tests that are isolated from dev data. When the test runs, I get the following:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.profiles.active' in string value "persistence-${spring.profiles.active}.properties"
What is going on here?