我有一个使用Maven进行管理的Java应用程序。该项目涉及的国家的概念,例如使用Spring的Maven构建和依赖注入
public interface ICountry {
public void doSomething();
}
public class England implements ICountry {...}
public class Brazil implements ICountry {...}
public class CountryApp {
public static void main (String args[]) {
ICountry country = null;
// PSEUDOCODE:
// Retrieve a chosen implementation of ICountry using Spring
country.doSomething();
}
}
从我看到的Spring我可能有一个Spring配置文件为每个国家。看起来可以使用Maven profiles使用配置文件中的元素选择适当的配置文件。然而,文档说配置文件旨在支持在不同的环境中构建,而不是具有不同的应用程序配置。
这听起来像一个合理的方法吗?如果有人知道更好或更“标准”的方式,请让我知道:)
编辑:最终我想能够为每个国家创建一个.jar。例如
- MYAPP-england.jar,
- MYAPP-brazil.jar等
你想测试每个国家?或者您是否想根据测试环境选择合适的国家? – YMomb 2012-03-29 16:50:43
你如何确定应该使用哪个“国家”?使用DI注入这些国家似乎有点偏离。 – beerbajay 2012-03-29 16:51:18
Locale怎么样? – YMomb 2012-03-29 16:52:57