【问题标题】:How to deploy Spring Boot application to different URL on Tomcat?如何将 Spring Boot 应用程序部署到 Tomcat 上的不同 URL?
【发布时间】:2015-09-27 14:59:20
【问题描述】:

我正在使用mvn tomcat:deploy 和以下配置将我的 Spring Boot 应用程序构建并部署到 Tomcat 中:

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>http://127.0.0.1:8080/manager/text</url>
                <server>tomcat</server>
                <path>/${project.build.finalName}</path>
                <username>admin</username>
                <password>password</password>
            </configuration>
        </plugin>

    </plugins>
</build>

应用程序随后在/${project.artifactId} 运行。我想将应用程序部署到另一个 URL,最好在调用 Maven 部署命令时设置目标 URL。是否可以?如果是这样,我该如何实现?

【问题讨论】:

    标签: spring maven tomcat deployment


    【解决方案1】:

    您可以使用 -D 选项从命令行覆盖 maven 属性。

    要为您的应用指定另一个 url,有趣的属性是 maven.tomcat.portmaven.tomcat.path

    下面的命令行应该可以解决问题:

    mvn -Dmaven.tomcat.port=8181 -Dmaven.tomcat.path=/custom tomcat:deploy
    

    【讨论】:

    • 不行,部署路径和平时一样。
    猜你喜欢
    • 2016-01-16
    • 1970-01-01
    • 2014-08-17
    • 1970-01-01
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 2014-09-04
    相关资源
    最近更新 更多