【问题标题】:Maven Tomcat deploy plugin with profiles带有配置文件的 Maven Tomcat 部署插件
【发布时间】:2017-07-22 19:19:21
【问题描述】:

我试图在我的项目 pom.xml 文件中使用配置文件来控制我的 war 文件到特定服务器的部署。例如,我有一个本地配置文件和一个开发服务器配置文件。这是我设置个人资料的方式

<profiles>

    <profile>
        <id>local</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <property>
                <name>target</name>
                <value>local</value>
            </property>
        </activation>
        ...
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <url>http://10.16.21.60:8080/manager/text</url>
                        <server>localTomcat</server>
                        <path>/</path>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

    <profile>
        <id>dev</id>
        <activation>
            <property>
                <name>target</name>
                <value>dev</value>
            </property>
        </activation>
        ...
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <url>http://devserverurl:8080/manager/text</url>
                        <server>devTomcat</server>
                        <path>/</path>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

我在打电话

mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy

当我尝试这个时,我可以看到不是尝试连接到我的配置中提供的 IP 地址10.16.21.60,而是尝试连接到localhost。我在本地 settings.xml 文件中使用用户名和密码同时定义了 devTomcatlocalTomcat

如果我随后添加 -X 选项以获取更多信息,我可以在插件的调试输出中看到(强调添加

[调试] 配置 mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy from plugin realm ClassRealm [plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.2, parent: sun.misc .Launcher$AppClassLoader@5c647e05] [调试] 使用基本配置器配置 mojo 'org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy' --> [调试] (f) 字符集 = ISO-8859-1 [调试] (f) contextFile = .... [调试] (f) ignorePackaging = false [调试] (f) 模式 = 战争 [DEBUG] (f) 包装 = 战争 [调试] (f) 路径 = ... [调试] (f) 更新 = 假 [调试] (f) url = http://localhost:8080/manager/text [调试] (f) 版本 = 2.2 [调试] (f) 战争文件 = ... [调试] (f) 设置 = org.apache.maven.execution.SettingsAdapter@61874b9d [DEBUG] -- 结束配置 -- [INFO] 部署战争到 http://localhost:8080/... [DEBUG] 未指定用于身份验证的服务器 - 使用默认值

我的配置设置似乎没有得到遵守!我认为这可行的方式是,由于local 配置文件已激活,它将使用该配置。

我也尝试过简单地在我的&lt;build&gt; 部分定义插件,没有配置文件,效果相同。它总是尝试连接到 http://localhost:8080 而不进行身份验证。

可能值得注意的是,我也在为这个项目使用gwt-maven-plugin,我不知道这是否会干扰 tomcat 插件配置。

【问题讨论】:

    标签: maven tomcat gwt maven-tomcat-plugin gwt-maven-plugin


    【解决方案1】:

    好的,原来我为插件使用了错误的groupID。不是

    <groupId>org.codehaus.mojo</groupId>
    

    是的

    <groupId>org.apache.tomcat.maven</groupId>
    

    现在像冠军一样工作!

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      相关资源
      最近更新 更多