我创建了这个配置文件,用于通过 SCP 在服务器上部署工件。我知道 Ant 的 scp 任务是可选的,因此我添加了依赖项。
<profiles>
<profile>
<id>remote-deploy</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>scp</id>
<phase>install</phase>
<configuration>
<tasks>
<scp .../>
<sshexec .../>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.42</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
但是,当我运行配置文件时,我最终得到
发生 Ant BuildException:问题:无法创建任务或键入 scp 原因:未找到类 org.apache.tools.ant.taskdefs.optional.ssh.Scp。这看起来像是 Ant 的可选组件之一。操作:检查 -ANT_HOME\lib -IDE Ant 配置对话框中是否存在适当的可选 JAR
不要惊慌,这是一个普遍的问题。最常见的原因是缺少 JAR。
这不是错误;这是一个配置问题
maven 是否有可能无法下载这些依赖项,或者它只是忽略了它们?