What's wrong with Jsch and Maven?

让人想犯罪 __ 提交于 2019-12-07 12:12:29

问题


I try to use Jsch 0.1.44 together with Maven.

I have the following dependency in my pom.xml.

<dependency>
    <groupId>com.jcraft</groupId>
    <artifactId>jsch</artifactId>
    <version>0.1.44</version>
    <scope>compile</scope>
</dependency>

If I run mvn compile maven looks normal and tells me that Jsch has been successful downloaded.

But when it comes to compile, the Jsch classes could not be found. If I look into my local repository I can see that the Jsch-jar has only a size of 3kb. If I open the jar file I can also see that there is only the META-INF folder.

So what is wrong here, how can I fix this?


回答1:


For some reason the jar file in the central repository seems to be broken. The solution is to add another repository for Jsch to the pom.xml.

<repository>
    <id>Jsch</id>
    <url>http://jsch.sf.net/maven2/</url>
</repository>



回答2:


There are different possibilities:

  • You have used the correct Maven repository for jsch (seems to be this one: http://mvnrepository.com/artifact/com.jcraft/jsch/0.1.44-1), but the download stopped for whatever reason. This happens, and you have just to clear your local repository by deleting the directory for jsch or the the version only. It will be reloaded again.
  • Perhaps you has misconfigured your remote repository for jsch, and jsch is hold somewhere, but not the library, only the meta data. I do not know if it is possible to see from which location you got the wrong library.

You should look at your settings.xml (for Maven or your user) and see if the repository is specified correctly.

You should check if the command

mvn dependency:get -DrepositoryUrl=http://mvnrepository.com/artifact/ \
                   -DgroupId=com.jcraft -DartifactId=jsch -Dversion=0.1.44 \
                   -Dtransitive=false

works properly.




回答3:


0.1.44 version is broken (it's only 3KB)

http://mvnrepository.com/artifact/com.jcraft/jsch/0.1.44

use http://mvnrepository.com/artifact/com.jcraft/jsch/0.1.44-1 Instead

update your POM to this:

<dependency>
  <groupId>com.jcraft</groupId>
  <artifactId>jsch</artifactId>
  <version>0.1.44-1</version>
</dependency>


来源:https://stackoverflow.com/questions/7572457/whats-wrong-with-jsch-and-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!