Eclipse - So ändern Sie den Web-Projektkontextstamm

Eclipse - So ändern Sie das Stammverzeichnis des Webprojektkontexts

Wenn Sie ein Webprojekt in Eclipse ausführen oder debuggen, wird der Projektname als Standard-Kontextstamm verwendet. Beispiel: Ein Projekt mit dem Namen "springmvc" ist das Standard-Kontextstammverzeichnis

http://localhost:8080/springmvc

Getestete Technologien:

  1. Eclipse 4.4

  2. Eclipse Tomcat-Server-Plugin

  3. Maven 3

  4. Gradle 2.0

Note
Das Kontextstammverzeichnis gibt die URL einer bereitgestellten Webanwendung an.

http://localhost:8080/{context_root}

In diesem Lernprogramm zeigen wir Ihnen einige Möglichkeiten zum Aktualisieren des Webprojekt-Kontextstamms in der Eclipse-IDE.

1. Eclipse - Webprojekteinstellungen

eclipse-context-root-solution1

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. Das Kontextstammverzeichnis sollte aktualisiert werden.
1.3 Wenn Schritt 2 fehlschlägt, löschen Sie den Server, erstellen Sie einen neuen Server und fügen Sie die Web-App wieder hinzu.

Neue Kontextwurzel:http://localhost:8080/abc

2. Eclipse - Web Module

eclipse-context-root-solution2

2.1 Double click on the Eclipse server plugin.
2.2 Clicks on the Modules tab.
2.3 Update the Path.
2.4 Done. Starten Sie den Server neu.

Neue Kontextwurzel:http://localhost:8080/abc

3. Maven Eclipse Plugin

3.1 Define the new context root in wtpContextName.

pom.xml

    
        org.apache.maven.plugins
        maven-eclipse-plugin
        2.9
        
            2.0
            abc
        
    

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