我正在使用带有 Eclipse 4.21 和 Java 1.8 的 2019 Macbook Pro
我在运行 jcifs 依赖项 ( https://www.jcifs.org/ ) 提供的网络文件访问代码时遇到以下异常,这是我试图从https 的 API 文档实现的代码:/ /www.jcifs.org/src/docs/api/进入我自己的项目
import jcifs.smb.*;
jcifs.Config.setProperty( "jcifs.netbios.wins", "192.168.1.220" );
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password");
SmbFileInputStream in = new SmbFileInputStream("smb://host/c/My Documents/somefile.txt", auth);
byte[] b = new byte[8192];
int n;
while(( n = in.read( b )) > 0 ) {
System.out.write( b, 0, n );
}
根据本网站上找到的有关如何添加 jcifs 依赖项的一些指南,我将其添加到项目中
箭头指向我正在运行的实际项目,即 Kura 模拟器,它启动了一个 jersey 服务器并提供了一些用于测试网络文件访问代码的路由。
这是模拟器项目的结构
我没有创建模拟器项目,它来自 ESF 7 工作区/项目导入
依赖项存在于 pom.xml
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
<type>jar</type>
</dependency>
导入存在
import jcifs.smb.*;
这是我项目中的代码片段
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password");
SmbFileInputStream in = new SmbFileInputStream("smb://server/Users/user/Public/test.txt");
byte[] b = new byte[8192];
int n;
while(( n = in.read( b )) > 0 ) {
System.out.write( b, 0, n );
}
这是我得到的错误
2021-10-12 15:47:12.768:WARN:oejs.HttpChannel:qtp146098308-130: /services/labedge
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: jcifs/smb/NtlmPasswordAuthentication
jcifs 库提供的任何类都会发生此错误,就好像在实际调用该类时它无法找到它,即使它已被代码识别。
所以我认为解决方案是让它能够真正找到课程,但对于我的生活,我似乎无法弄清楚如何。
有人有想法吗?
谢谢。