开发环境
@Profile({"dev", "local"})
@Configuration
public class ModuleDevConfiguration {
@Value("${app.name}")
private String appKey;
@Profile({"dev", "local"})
@Configuration("anticorruptionDevConfiguration")
@PropertySources({
@PropertySource("classpath:common.properties"),
@PropertySource("classpath:dev/dev.properties")
})
public static class Dev {
}
}
测试与线上环境
@Profile({"test", "staging", "prod"})
@Configuration
public class ModuleNotDevConfiguration {
@Value("${app.name}")
private String appKey;
@Profile("test")
@Configuration("anticorruptionTestConfiguration")
@PropertySources({
@PropertySource("classpath:common.properties"),
@PropertySource("classpath:test/test.properties")
})
public static class Test {
}
@Profile({"staging", "prod"})
@Configuration("anticorruptionOnlineConfiguration")
@PropertySources({
@PropertySource("classpath:common.properties"),
@PropertySource("classpath:prod/prod.properties")
})
public static class Online {
}
}