簡體   English   中英

如何將Pom文件中的完整URL名稱替換為本地主機

[英]How to replace a localhost with meaning full URL name in pom file

我的應用程序在URL上的本地主機上運行,​​即http://localhost:8080/WebIntegrationApp 有什么方法可以將pom.xml文件中的http://localhost:8080/WebIntegrationApp URL替換為http://WebIntegrationApp 我的意思是我想使用url http://WebIntegrationApp運行此應用程序。

使用的操作系統是Windows7,這是用於為本地主機運行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>

是。 您可以使用任何文本編輯器來編輯pom.xml

如果要在本地計算機上運行應用程序,則應編輯主機文件。 然后編輯你的pom.xml

在Windows系統主機上,位於:Windows \\ System32 \\ drivers \\ etc \\在Linux上:/ etc / hosts

這與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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM