更改Jetty网址

huangapple go评论64阅读模式
英文:

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.

&lt;plugin&gt;
  &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
  &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;9.4.31.v20200723&lt;/version&gt;
  &lt;configuration&gt;
    &lt;scanIntervalSeconds&gt;10&lt;/scanIntervalSeconds&gt;
    &lt;webApp&gt;
      &lt;contextPath&gt;/&lt;/contextPath&gt; &lt;!-- this line is the important one --&gt;
    &lt;/webApp&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;

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

huangapple
  • 本文由 发表于 2020年8月25日 01:09:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/63565633.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定