Java - How to change context root of a dynamic web project in eclipse

时间:2023-02-05 17:52:16

I'm sure you've moved on by now, but I thought I'd answer anyway.

Some of these answers give work-arounds. What actually must happen is that you clean and republish your project to "activate" the new URI. This is done by right-clicking your server (in the Servers view) and choosing Clean. Then you start (or restart it). Most of the other answers here suggest you do things that in effect accomplish this.

The file that's changing is workspace/.metadata/.plugins/org.eclipse.wst.server.core/publish/publish.datunless, that is, you've got more than one server in your workspace in which case it will be publishN.dat on that same path.

Hope this helps somebody.


Not sure if this is proper etiquette or not -- I am editing this answer to give exact steps for Eclipse Indigo.

(1) In your project's Properties, choose "Web Project Settings".

(2) Change "Context root" to "app".

Java - How to change context root of a dynamic web project in eclipse

(3) Choose Window > Show View > Servers.

(4) Stop the server by either clicking the red square box ("Stop the server" tooltip) or context-click on the server listing to choose "Stop".

(5)On the server you want to use, context-click to choose "Clean…".

Java - How to change context root of a dynamic web project in eclipse

(6) Click OK in this confirmation dialog box.

Java - How to change context root of a dynamic web project in eclipse

Now you can run your app with the new "app" URL such as:

http://localhost:8080/app/

Doing this outside of Eclipse, on your production server, is even easier --> Rename the war file. Export your Vaadin app as a WAR file (File > Export > Web > WAR file). Move the WAR file to your web server's servlet container such as Tomcat. Rename your WAR file, in this case to "app.war". When you start the servlet container, most such as Tomcat will auto-deploy the app, which includes expanding the war file to a folder. In this case, we should see a folder named "app". You should be good to go. Test your URL. For a domain such as "example.com" this would be: http://www.example.com/app/

Thanks so much to Russ Bateman for posting the correct answer to this frustrating problem.

Vaadin toolkit programmers may need to rebuild their widget set if using visual add ons.

--Basil Bourque



原地址 :http://*.com/questions/2437465/java-how-to-change-context-root-of-a-dynamic-web-project-in-eclipse