Eclipse How to change web project context root

摘要: If you run or debug a web project in Eclipse, the project name will be the default context root. For example, a project named “springmvc”, the default context root will be

If you run or debug a web project in Eclipse, the project name will be the default context root. For example, a project named “springmvc”, the default context root will be

http://localhost:8080/springmvc

Technologies tested :

  1. Eclipse 4.4
  2. Eclipse Tomcat server plugin
  3. Maven 3
  4. Gradle 2.0
Note
The context root tell you the URL of a deployed web application.

http://localhost:8080/{context_root}

In this tutorial, we will show you a few ways to update the web project context root in the Eclipse IDE.

1. Eclipse – Web Project Settings

1.1 Right click on the project, select Properties, Web Project Settings, update the context root here.
1.2 Remove your web app from the server and add it back. The context root should be updated.
1.3 If step 2 is failing, delete the server, create a new server and add back the web app.

New context root : http://localhost:8080/abc

2. Eclipse – Web Modules

2.1 Double click on the Eclipse server plugin.
2.2 Clicks on the Modules tab.
2.3 Update the Path.
2.4 Done. Restart the server.

New context root : http://localhost:8080/abc

3. Maven Eclipse Plugin

3.1 Define the new context root in wtpContextName.

pom.xml
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-eclipse-plugin</artifactId>
		<version>2.9</version>
		<configuration>
			<wtpversion>2.0</wtpversion>
			<wtpContextName>abc</wtpContextName>
		</configuration>
	</plugin>

3.2 Issue below command to recreate the Eclipse settings.

$ mvn eclipse:cleanEclipse eclipse:eclipse

4. Gradle Eclipse Plugin

4.1 Define the eclipse wtp settings.

build.gradle
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
//For Eclipse IDE only
eclipse {
  wtp {
    component {
      contextPath = 'abc'

4.2 Issue below command to recreate the Eclipse settings.

$ gradle clenEclipse eclipse

References

  1. Gradle The Eclipse Plugin
  2. Gradle EclipseWtpComponent example
  3. Maven Eclipse Plugin

上一篇: Combine Spring validator and Hibernate validator
下一篇: Maven Jetty Plugin Examples
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号