英文:
Change Jetty URL
问题
我刚刚建立了一个名为"music-store-api"的基本Jetty项目。要通过Jetty访问我的项目,我会前往http://localhost:8090/music-store-api/hello-world
。我想知道如何从URL中去除"music-store-api"部分,使其变成http://localhost:8090/hello-world
。
英文:
I have just set up a basic Jetty project named music-store-api. To access my project through Jetty I would go to http://localhost:8090/music-store-api/hello-world
. I am wondering how I would remove the music-store-api part from the URL so it becomes http://localhost:8090/hello-world
?
答案1
得分: 2
将“context path”更改为根路径,即“/”。
根据您的音乐应用程序部署方式,有几种不同的方法可以实现此目标。
由于您正在使用jetty-maven-plugin
及其jetty:run
目标,您需要编辑您的pom.xml
。
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.31.v20200723</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath> <!-- 这一行很重要 -->
</webApp>
</configuration>
</plugin>
来源:https://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#configuring-your-webapp
英文:
Change the context path
to root, aka "/".
Depending on how you have your music app deployed, there's a few different ways to accomplish this.
Since you are using jetty-maven-plugin
and it's jetty:run
goal, you'll need to edit your pom.xml
.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.31.v20200723</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath> <!-- this line is the important one -->
</webApp>
</configuration>
</plugin>
From: https://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#configuring-your-webapp
答案2
得分: 0
我按照说明在 https://www.eclipse.org/jetty/documentation/current/configuring-specific-webapp-deployment.html 上修改了 contextPath
。
英文:
I followed the instructions tp modify the contextPath
on https://www.eclipse.org/jetty/documentation/current/configuring-specific-webapp-deployment.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论