Java 如何在pom文件中将localhost替换为完整的URL名称
我的应用程序正在URL上的本地主机上运行,即Java 如何在pom文件中将localhost替换为完整的URL名称,java,maven,maven-2,maven-tomcat-plugin,Java,Maven,Maven 2,Maven Tomcat Plugin,我的应用程序正在URL上的本地主机上运行,即http://localhost:8080/WebIntegrationApp。 有没有办法替换http://localhost:8080/WebIntegrationAppurl和http://WebIntegrationApp在pom.xml文件中。 我的意思是我想使用urlhttp://WebIntegrationApp 使用的操作系统是windows7,下面是用于运行tomcat for localhost的插件: org.apache.to
http://localhost:8080/WebIntegrationApp
。
有没有办法替换http://localhost:8080/WebIntegrationApp
url和http://WebIntegrationApp
在pom.xml文件中。
我的意思是我想使用urlhttp://WebIntegrationApp
使用的操作系统是windows7,下面是用于运行tomcat for localhost的插件:
org.apache.tomcat.maven
tomcat7 maven插件
2.2
http://localhost:8080/manager/text
本地服务器
/WebIntegrationApp
管理
s3cret
雄猫赛跑
只管打仗
预集成测试
符合事实的
tomcat关机
关闭
整合后测试
是。你可以使用任何文本编辑器编辑pom.xml如果你想在本地机器上运行你的应用程序,你应该编辑你的主机文件。然后编辑pom.xml
位于windows系统主机上的:windows\System32\drivers\etc\
在linux上:/etc/hosts这与maven无关,
maven tomcat插件只负责运行已配置的web应用程序
它将使用附加到端口(默认值为8080)并后跟webapp上下文名称的提供的服务器(localhost);您的是WebIntegrationApp
您试图实现的目标可以通过使用前端服务器来实现,例如配置一些路由规则,以便在点击http://localhost:8080/WebIntegrationApp
在浏览器中,您将被重定向到http://WebIntegrationApp
。
在幕后,会有一个反转机制,所以当你点击http://WebIntegrationApp
;在后台,请求被发送到http://localhost:8080/WebIntegrationApp
如果您不习惯使用apachehttpd服务器,这将需要一些配置。以下是您必须缩短行的VirtualHost配置:
<VirtualHost *:80>
ServerName Enter your server DNS name here
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" http://localhost:8080/
ProxyPassReverse "/" http://localhost:8080/
</VirtualHost>
ServerName在此处输入您的服务器DNS名称
代理请求关闭
代理主机
ProxyPass“/”http://localhost:8080/
ProxyPassReverse“/”http://localhost:8080/
谢谢您的回答。我想这不是一个好主意。如果这个文件必须由不同的用户使用,那么每个人都必须编辑主机文件。所以我在寻找一个通用的解决方案。一个改变对其他人有效。然后你应该配置你的DNS服务器设置。