Reputation: 534
In my tomcat project I have a configuration folder, in path src/main/tomcatconf
.
Now I want to deploy to 2 different servers. A development server and a production one.
I run my development server with mvn tomcat:run. Running my server on the fly, and all work perfectly.
Now I want to add the production server, with a different configuration folder (ie src/main/production/tomcatconf
) and deploy the .war on Tomcat instance in my filesystem (ie /opt/tomcat6
)
with mvn tomcat:deploy command.
How can i do this ?
Upvotes: 3
Views: 1443
Reputation: 534
Finally i used maven resource plugin with profile configuration.
i've made two additional folder :
src/main/production
src/main/development,
then i move my Meta-inf/persistence.xml in these folder.
then i add this part of configuration on my pom.xml :
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>environment.type</name>
<value>dev</value>
</property>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/development</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>production</id>
<activation>
<property>
<name>environment.type</name>
<value>prod</value>
</property>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/production</directory>
</resource>
</resources>
</build>
</profile>
</profiles>
in this manner i've a common resource folder and an additional folder based by environment type.
Now when i run
mvn tomcat:run -Denvironment.type=dev
i use my development environment and when i run
mvn tomcat:run -Denvironment.type=prod
i use my production enviroment.
The only drawback of this approach is that everytime i want change environment type i must run
mvn clean
to build the right configuration file.
Please let me know If you Think that i wrong or you want suggest another kind of solution
Regards Antonio Musella
Upvotes: 1