Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating Spring Profile active JVM arguments in GWT hosted mode

I have a spring profile configuration as shown below

<beans profile="dev">
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${db.driverClassName}" />
        <property name="jdbcUrl" value="dfgdfg" />
        <property name="user" value="${db.username}" />
        <property name="password" value="${db.password}" />
    </bean>
</beans>

<beans profile="prod">
    <jee:jndi-lookup id="dataSource" jndi-name="jdbc/Test"/>
</beans>

I am trying to make one of this active via the VM argument -Dspring.profiles.active="dev" . This works in Tomcat and so does the context-param route in Hosted mode via the gwt-maven-plugin but I can't get the VM arguments to work . I tried mvn -Dspring.profiles.active="dev" gwt:run also tried to pass -Dspring.profiles.active="dev" via the VM arguments under the JRE tab in run configurations along with the goal gwt:run . I also tried the environment tab and even -Dspring.profiles.active=dev but the NoSuchBeanDefinitionException doesn't budge . Is this because of the limited capability of the embedded server ?

like image 832
Aravind A Avatar asked Feb 02 '12 19:02

Aravind A


1 Answers

No, simply gwt:maven plugin is kind of strange and it doesn't pass system properties to the launched JVM instance, and the only way to pass parameters is to put it into <extraJvmArgs> in plugin configuration e.g. in your case you have to add following to the configuration tag of gwt plugin:

<extraJvmArgs>-Dspring.profiles.active=dev</extraJvmArgs>

God knows why this works only this way, I wish there were some other normal way.

like image 89
jusio Avatar answered Oct 14 '22 13:10

jusio