Spring Standalone running with JVM Parameters

and using bean definitions based on them.

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
 
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
 
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>biz.tugay</groupId>
    <artifactId>spring-hello</artifactId>
 
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
 
    <name>spring-hello</name>
    <url>http://maven.apache.org</url>
 
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.0.5.RELEASE</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
 
</project>

beans.xml
<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <import resource="beans-${targetPlatform}.xml"/>
 
</beans>

beans-PROD.xml
<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <bean id="myService" class="biz.tugay.MyServiceForProdImpl">
    </bean>
 
</beans>

beans-DEV.xml
<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <bean id="myService" class="biz.tugay.MyServiceForDevImpl">
    </bean>
 
</beans>

And just run the application like:

-DtargetPlatform=DEV

or

-DtargetPlatform=PROD

to pick the bean definition file you like!