【问题标题】:How to replace a localhost with meaning full URL name in pom file如何在 pom 文件中用完整的 URL 名称替换 localhost
【发布时间】:2014-08-28 12:35:17
【问题描述】:

我的应用程序在我的 localhost 上的 URL 上运行,即http://localhost:8080/WebIntegrationApp。 有没有办法在 pom.xml 文件中用http://WebIntegrationApp 替换http://localhost:8080/WebIntegrationApp url。 我的意思是我想使用 url http://WebIntegrationApp 运行这个应用程序。

使用的操作系统是windows7,这里是用于localhost运行tomcat的插件:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://localhost:8080/manager/text</url>
        <server>localhost</server>
        <path>/WebIntegrationApp</path>
        <username>admin</username>
        <password>s3cret</password>

    </configuration>
    <executions>
        <execution>
            <id>tomcat-run</id>
            <goals>
                <goal>run-war-only</goal>
            </goals>
            <phase>pre-integration-test</phase>
            <configuration>
                <fork>true</fork>
            </configuration>
        </execution>

        <execution>
            <id>tomcat-shutdown</id>
            <goals>
                <goal>shutdown</goal>
            </goals>
            <phase>post-integration-test</phase>
        </execution>
    </executions>
</plugin>

【问题讨论】:

    标签: java maven maven-2 maven-tomcat-plugin


    【解决方案1】:

    是的。您可以使用任何文本编辑器来编辑 pom.xml

    【讨论】:

      【解决方案2】:

      如果你想在本地机器上运行你的应用程序,你应该编辑你的主机文件。然后编辑你的 pom.xml

      在 Windows 系统主机上:Windows\System32\drivers\etc\ 在 Linux 上:/etc/hosts

      【讨论】:

      • 感谢您的回答。我想这不是一个好主意。如果这个文件必须由不同的用户使用,那么每个人都必须编辑主机文件。所以我正在寻找一个通用的解决方案。一个改变适用于其他人。
      • 那么你应该配置你的DNS服务器设置。
      【解决方案3】:

      这与maven无关,maven-tomcat-plugin只负责运行配置好的web应用。

      它将使用提供的服务器 (localhost) 附加到端口(默认为 8080)并后跟 webapp 上下文名称;你的是 WebIntegrationApp

      您尝试实现的目标可以通过配置一些路由规则使用诸如Apache Httpd 之类的前端服务器来完成,因此当您在浏览器中点击http://localhost:8080/WebIntegrationApp 时,您将被重定向到http://WebIntegrationApp。 而在幕后,会有一个反转机制,所以当你点击 http://WebIntegrationApp;在后台,请求被发送到 http://localhost:8080/WebIntegrationApp

      如果您不熟悉 Apache Httpd Server,则需要进行一些配置。这是您应该缩短行的 VirtualHost 配置:

      <VirtualHost *:80>
        ServerName      Enter your server DNS name here
        ProxyRequests   Off
        ProxyPreserveHost On
        ProxyPass  "/" http://localhost:8080/
        ProxyPassReverse "/" http://localhost:8080/
      </VirtualHost>
      

      【讨论】:

        猜你喜欢
        • 2016-06-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-10
        • 1970-01-01
        • 2011-09-20
        相关资源
        最近更新 更多