Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set context path to root("/") in Tomcat 7.0 when using Maven

I hava a maven project, pom.xml contains tomcat plugin.

<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.2</version>
</plugin>

I've downloaded Tomcat 7, so I've got Tomcat directory (apache-tomcat-7.0.56). I tried three goals to run my project:

tomcat7:run, tomcat7:run-war, tomcat7:run-war-only

My application is running at http://localhost:8080/projectname, if I run tomcat7:run-war, projectname-0.0.1-SNAPSHOT.war appears in the /target directory of my project.

I want to run my application at http://localhost:8080/.

I know this question was asked before, but unfortunately those solutions didn't help me.

I tried both methods from the first answer of this.

First method didn't work for me, after renaming war nothing changed, tomcat7:run-war-only requires war with name like projectname-0.0.1-SNAPSHOT.war.

The second method changed nothing (I tried both

<Context path="" docBase="projectname-0.0.1-SNAPSHOT" debug="0" reloadable="true"></Context>
and

<Context path="" docBase="projectname" debug="0" reloadable="true"></Context>)

I have also looked throw this, but I don't have <catalina_home>/conf/Catalina/localhost/ directory in my Tomcat directory.

like image 410
Bogdan Timofeev Avatar asked Nov 11 '14 09:11

Bogdan Timofeev


Video Answer


1 Answers

Have you tried changing the context path by setting it in the configuration section of the Maven plugin?

FYI: Find the current version of the plugin here

  <plugin>
   <groupId>org.apache.tomcat.maven</groupId>
   <artifactId>tomcat7-maven-plugin</artifactId>
   <version>2.2</version>

    <configuration>
      <path>/</path>
    </configuration>

  </plugin>
like image 125
Stefan Avatar answered Oct 05 '22 21:10

Stefan