maven jetty 插件 - 从 url 中删除本地主机/服务器名称 [英] maven jetty plugin - remove localhost/server name from url

查看:30
本文介绍了maven jetty 插件 - 从 url 中删除本地主机/服务器名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 maven jetty 插件运行我的 Web 应用程序.我可以通过 localhostipserver name 访问我的 Web 应用程序.

i am running my web application using maven jetty plugin. I can access my web application either through localhost, ip or server name.

但是假设我想使用应用程序名称访问我的应用程序.

例如

http://ip:port/login/login.jsp
http://servername:port/login/login.jsp

我想要类似的东西,没有端口或 IP.

http://applicationname/login/login.jsp

pom.xml

           <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>8.1.9.v20130131</version>
                <configuration>
                    <connectors>
                        <connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
                            <port>port</port>
                        </connector>
                    </connectors>
                    <stopPort>18080</stopPort>
                    <scanIntervalSeconds>0</scanIntervalSeconds>
                    <webXml>target/classes/WEB-INF/web.xml</webXml>
                    <!-- <webApp> <contextPath>/</contextPath> </webApp> -->

                </configuration>
            </plugin>

推荐答案

不确定是否可以使用 maven-jetty-plugin 或其他方式完成.Jetty 是一个 servlet 容器,它运行在操作系统中并在指定的端口上侦听 http 请求.这是无法更改的.

Not sure if it can be done using maven-jetty-plugin or other. Jetty is a servlet container which is running in a operating system and listening on a specified port for http requests. This cannot be changed.

然而,为了实现你所需要的,你可以修改主机文件(linux:/etc/hosts;windows:%SystemRoot%\System32\drivers\etc\hosts).看看https://en.wikipedia.org/wiki/Hosts_(file).

However to achieve what you need you can modify hosts file (linux: /etc/hosts; windows: %SystemRoot%\System32\drivers\etc\hosts). Take a look at https://en.wikipedia.org/wiki/Hosts_(file).

您的主机配置可能类似于:127.0.0.1 应用名称

Your hosts configuration could like like: 127.0.0.1 applicationname

请记住,您无法定义端口名称.另请记住,这不是您的应用程序配置,而是您托管应用程序的主机配置.

Keep in mind that you cannot define the port name. Also keep in mind that this is not your application configuration but configuration of host where you're hosting your app.

这篇关于maven jetty 插件 - 从 url 中删除本地主机/服务器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆