【问题标题】:Maven Cargo Plugin Multiple Executions: Username and Password are MandatoryMaven Cargo 插件多次执行:用户名和密码是强制性的
【发布时间】:2021-08-29 15:18:20
【问题描述】:

我正在尝试使用 Cargo 插件部署到一个简单的 Tomcat 集群环境,有两个 Tomcat 节点:

  • tomcat1 (192.168.10.21)
  • tomcat2 (192.168.10.22)

尝试运行mvn cargo:deploy 时出现以下错误:

[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven3-plugin:1.9.4:deploy
 (default-cli) on project sample: Execution default-cli of goal 
org.codehaus.cargo:cargo-maven3-plugin:1.9.4:deploy failed: The 
[cargo.remote.username] and [cargo.remote.password] properties are 
mandatory and need to be defined in your configuration. -> [Help 1]

我在两次执行中都指定了用户名和密码,但都没有成功。我的 pom.xml 的 <build> 部分如下。有人可以帮忙吗?

编辑:提供整个 POM.xml 而不仅仅是构建部分。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.0</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <groupId>org.jason</groupId>
  <artifactId>sample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>sample</name>
  <packaging>war</packaging>
  <description>Sample Project for Testing Cluster Setup</description>

  <properties>
    <java.version>11</java.version>
    <cargo.remote.username>jason</cargo.remote.username>
    <cargo.remote.password>password</cargo.remote.password>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>

<!--    <dependency>-->
<!--      <groupId>org.springframework.boot</groupId>-->
<!--      <artifactId>spring-boot-starter-test</artifactId>-->
<!--      <scope>test</scope>-->
<!--    </dependency>-->
<!--    <dependency>-->
<!--      <groupId>org.springframework.security</groupId>-->
<!--      <artifactId>spring-security-test</artifactId>-->
<!--      <scope>test</scope>-->
<!--    </dependency>-->
  </dependencies>

  <build>
      <finalName>sample</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven3-plugin</artifactId>
        <version>1.9.4</version>
        <configuration>
          <container>
            <containerId>tomcat9x</containerId>
            <type>remote</type>
          </container>
          <configuration>
            <type>runtime</type>
            <properties>
              <cargo.protocol>http</cargo.protocol>
              <cargo.servlet.port>8080</cargo.servlet.port>
            </properties>
          </configuration>
          <deployer>
            <type>remote</type>
          </deployer>
          <deployables>
            <deployable>
              <groupId>org.jason</groupId>
              <artifactId>sample</artifactId>
              <type>war</type>
            </deployable>
          </deployables>
        </configuration>
        <executions>
          <execution>
            <id>tomcat1</id>
            <configuration>
              <properties>
<!--                <cargo.remote.username>jason</cargo.remote.username>-->
<!--                <cargo.remote.password>password</cargo.remote.password>-->
                <cargo.hostname>192.168.10.21</cargo.hostname>
              </properties>
            </configuration>
          </execution>
          <execution>
            <id>tomcat2</id>
            <configuration>
              <properties>
<!--                <cargo.remote.username>jason</cargo.remote.username>-->
<!--                <cargo.remote.password>password</cargo.remote.password>-->
                <cargo.hostname>192.168.10.22</cargo.hostname>
              </properties>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

【问题讨论】:

    标签: maven maven-cargo


    【解决方案1】:

    我猜你需要在 POM 的 &lt;properties&gt; 部分中定义它们,而不是在插件的配置中。

    【讨论】:

    • 我曾尝试过,但又这样做了。错误仍然存​​在。我在运行mvn clean install 之后也运行了该命令。我已经编辑了我的问题并发布了整个 pom.xml。
    猜你喜欢
    • 1970-01-01
    • 2011-04-17
    • 2017-04-13
    • 1970-01-01
    • 2012-10-29
    • 2012-06-30
    • 2011-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多