下面的行为发生在我调用getSftpUtil()时。我还确保了所有适当的jars都在maven项目的外部库中,并且可以在项目的WEB-INF/lib文件夹中获得
码
net.sf.opensftp.SftpUtil util = SftpUtilFactory.getSftpUtil();
堆栈跟踪
SftpUtilFactory: Trying to get SftpUtil class name from the system property net.sf.opensftp.SftpUtil
SftpUtilFactory - Trying to get SftpUtil class name from the system property net.sf.opensftp.SftpUtil
SftpUtilFactory: The system property net.sf.opensftp.SftpUtil is not set.
SftpUtilFactory - The system property net.sf.opensftp.SftpUtil is not set.
SftpUtilFactory: Use the default one.
SftpUtilFactory - Use the default one.
Caused by: java.lang.NoSuchMethodError: com.jcraft.jsch.JSch.setLogger(Lcom/jcraft/jsch/Logger;)V
at net.sf.opensftp.impl.SftpUtil.<clinit>(SftpUtil.java:110)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at net.sf.opensftp.SftpUtilFactory.getSftpUtil(SftpUtilFactory.java:184)发布于 2013-06-13 18:36:25
基于jcraft的变更日志,setLogger是在jsch-0.1.30中添加到JSch.java中的一种方法。因此,WEB/lib下的jar应该是一个旧版本。
你可以跑
mvn dependency:tree要查看哪些依赖项正在使用旧版本,然后使用以下内容将其排除在外:
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<exclusions>
<exclusion>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</exclusion>
</exclusions>
</dependency>您可能还有另一个依赖项引用了最近版本的jsch,因此您的问题应该在这一点上得到解决。但是,如果不是这样,则可以将其添加到pom.xml中:
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.50</version>
</dependency>发布于 2013-06-13 18:16:24
好吧,我想你错过了这种依赖关系或正确的版本:
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.49</version> <!--latest version -->https://stackoverflow.com/questions/17094126
复制相似问题