1. Add the following user-roles and user (specially a user with roles of manager-jmx,manager-script, see ‘maven’ user, for example) in tomcat-users.xml file. (Sidenote: you can create a user with manager-gui role to access Tomcat manager interface from your browser, that’s pretty cool and handy!!)
<!--This file is located in %TOMCAT_HOME%/conf/tomcat-users.xml -->
<?xml version='1.0' encoding='utf-8'?>

  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <user username="admin" password="tomcat" roles="manager-gui"/>
  <user username="maven" password="tomcat" roles="manager-jmx,manager-script"/>

  1. Add above Tomcat’s user (‘maven’ user in this case) in the Maven setting file, later Maven will use this user to login Tomcat server.( N.B. In case of a project running in IntelliJ, view/create maven settings.xml file from POM –> MAVEN –> Open Settings.xml (Or Create Settings.xml, if settings.xml is not present).)
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">


  1. Declare a maven-tomcat plugin in pom.xml.

Here, we are configuring maven-tomcat plugin to access TomcatServer with credentials defined in maven’s settings.xml file and deploy our app in this context path /mycoolapp.

  1. Run Tomcat Server (from command line %TOMCAT_HOME%/bin/startup.sh).

  2. Now execute this command from your project> maven tomcat7:deploy to deploy your war file in Tomcat. You should get a BUILD SUCCESS message if everything goes well.