You can put the variable in your maven development and development profiles and map it to java bean.
Here is the profile bit
<profiles>
<profile>
<id>prod</id>
<properties>
<system.serverType>PROD</system.serverType>
</properties>
</profile>
<profile>
<id>qa</id>
<properties>
<system.serverType>QA</system.serverType>
</properties>
</profile>
</profiles>
Then in /src/main/resources/applicationContext.xml
<bean id="system" class="com.company.project.System"
p:serverType="${system.serverType}"
/>
Then it maps the build profile to your java class.
public class System {
public static enum ServerType {PROD, QA, DEV}
private ServerType serverType;
public void setServerType(ServerType serverType) {
this.serverType = serverType;
}
public ServerType getServerType() {
return serverType;
}
public boolean isProduction() {
return serverType == ServerType.PROD;
}
}
source
share