Deploying maven project to existing Tomcat server
Currently my project setup is such that when I do a clean and install my maven project it downloads the tomcat version mentioned in the pom.xml and deploys the war files to it.
I need to change the config such that war files are deployed to tomcat which I have manually downloaded, not a single maven download. This is to use the settings I configured for the manually loaded tomcat.
Is it possible? If so, how?
source to share
You can try tomcat-maven-plugin , which allows you to deploy over context.xml, exploded war or just war file into existing tomcat instances.
source to share
I know you will probably need the - Maven
one answer to this question - me too. However, I found that the easiest but most flexible task was to build a war with Maven and deploy it with ANT
. The tomcat-maven plugin was not strong enough for me because I needed to deploy a .war for a local install Tomcat
to AND install on a remote machine with scp
.
My file looks like this ANT
build.xml
:
<?xml version="1.0"?>
<target name="deploy_local">
<echo>Deploying .war to local Tomcat</echo>
<copy file="target/My.war" todir="/tomcat/webapps">
</copy>
</target>
<target name="deploy_production">
<echo>Deploying .war to production Tomcat</echo>
<move file="target/My.war" tofile="target/ROOT.war"/>
<scp file="target/ROOT.war"
trust="true"
todir="me:password@154.14.232.122:/tomcat/webapps"
port="22">
</scp>
</target>
You can see that I even renamed the .war file from My.war to ROOT.war for a production deployment.
Then follow this procedure: mvn clean package
then run a local or production target ANT
for deployment.
source to share