Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6110347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:30:19+00:00 2026-05-23T14:30:19+00:00

I use tomcat-maven-plugin to deploy my war to a server. What I have to

  • 0

I use tomcat-maven-plugin to deploy my war to a server. What I have to do is configure it like this in my pom.xml:

<configuration>
...
   <url>http://localhost/manager</url>
   <username>admin</username>
   <password>admin</password>
...
</configuration>

But then I obviously want to keep this settings in a different place since I work on my computer but then there’s a staging and a live server as well where the settings of the server are different.

So let’s use the .m2/settings.xml:

<servers>
    <server>
        <id>local_tomcat</id>
        <username>admin</username>
        <password>admin</password>
    </server>
</servers>

Now change the pom.xml:

<configuration>
    <server>local_tomcat</server>
</configuration>

But where to put the URL of the server? There’s no place for that in the settings.xml under the server tag! Maybe like this?

<profiles>
  <profile>
     <id>tomcat-config</id>
      <properties>
    <tomcat.url>http://localhost/manager</tomcat.url>
      </properties>
  </profile>
</profiles>

<activeProfiles>
   <activeProfile>tomcat-config</activeProfile>
</activeProfiles>

..and use the ${tomcat.url} property.

But then the question is, why use the server tag in settings.xml at all? Why not use properties for the username and password as well? Or is there a place for the URL as well in the settings URL so I don’t have to use properties?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:30:20+00:00Added an answer on May 23, 2026 at 2:30 pm

    First off let me say, profiles are one of the most powerful features of Maven.

    First make a profile in your pom.xml that looks like this:

    <profiles>
        <profile>
            <id>tomcat-localhost</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <tomcat-server>localhost</tomcat-server>
                <tomcat-url>http://localhost:8080/manager</tomcat-url>
            </properties>
        </profile>
    </profiles>
    

    Then in your ~/.m2/settings.xml file add servers entries like this:

       <servers>
           <server>
               <id>localhost</id>
               <username>admin</username>
               <password>password</password>
           </server>
        </servers>
    

    The configure your build plugin like this:

    <plugin>
        <!-- enable deploying to tomcat -->
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <version>1.1</version>
        <configuration>
            <server>${tomcat-server}</server>
            <url>${tomcat-url}</url>
        </configuration>
    </plugin>
    

    This will enabled your tomcat-localhost profile by default and allow you to deploy to it with a simple mvn clean package tomcat:deploy.

    To deploy to other targets, set up a new <server/> entry in settings.xml with the appropriate credentials. Add a new profile but leave off the <activation/> stanza and configure it to point to the appropriate details.

    Then to use it do mvn clean package tomcat:deploy -P [profile id] where the [profile id] is the new profile.

    The reason that credentials is set in the settings.xml is because your username and password should be secret in most cases, and there is no reason to deviate from the standard way of setting up server credentials that people will have to adapt to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use mvn tomcat:deploy of tomcat-maven-plugin there is a 403 error: Failed to
I have just started to use Apache Maven. Now I would like to make
I use Eclipse J2EE 3.5 with Maven and tomcat. To deploy my maven webapp
I have a maven project where I want to use the Cargo-Maven-Plugin (1.1.1) to
is it possible to run spring mvc application on tomcat(with this plugin http://mojo.codehaus.org/tomcat-maven-plugin/ )
We use Tomcat to host our WAR based applications. We are servlet container compliant
I wish to use the Tomcat install/deploy tasks from catalina-ant.jar to deploy a webapp
I have configured Tomcat to use LDAP / AD. How can I get more
I would like to use NTLM authentication with Tomcat so that Iexplorer send automatically
I'm about to use MySQL with Hibernate on a Tomcat 5.5.x server. Do I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.