开发环境

  1. @Profile({"dev", "local"})
  2. @Configuration
  3. public class ModuleDevConfiguration {
  4. @Value("${app.name}")
  5. private String appKey;
  6. @Profile({"dev", "local"})
  7. @Configuration("anticorruptionDevConfiguration")
  8. @PropertySources({
  9. @PropertySource("classpath:common.properties"),
  10. @PropertySource("classpath:dev/dev.properties")
  11. })
  12. public static class Dev {
  13. }
  14. }

测试与线上环境

  1. @Profile({"test", "staging", "prod"})
  2. @Configuration
  3. public class ModuleNotDevConfiguration {
  4. @Value("${app.name}")
  5. private String appKey;
  6. @Profile("test")
  7. @Configuration("anticorruptionTestConfiguration")
  8. @PropertySources({
  9. @PropertySource("classpath:common.properties"),
  10. @PropertySource("classpath:test/test.properties")
  11. })
  12. public static class Test {
  13. }
  14. @Profile({"staging", "prod"})
  15. @Configuration("anticorruptionOnlineConfiguration")
  16. @PropertySources({
  17. @PropertySource("classpath:common.properties"),
  18. @PropertySource("classpath:prod/prod.properties")
  19. })
  20. public static class Online {
  21. }
  22. }