TL;DR

  • 场景: Java 应用需要接入 FastDFS 分布式文件系统
  • 结论: 两种方式均可实现连接:源码编译或直接使用 Maven 依赖
  • 产出: 可直接复用的代码示例和配置模板

版本矩阵

组件/库版本已验证
happyfish100/fastdfs-client-java1.37-SNAPSHOT
cn.bestwu:fastdfs-client-java1.27
com.github.tobato:fastdfs-client1.27.2
Spring Boot2.4.1

方式一:源码编译

git clone https://github.com/happyfish100/fastdfs-client-java.git
cd fastdfs-client-java
mvn clean install

Maven 依赖:

<dependency>
    <groupId>org.csource</groupId>
    <artifactId>fastdfs-client-java</artifactId>
    <version>1.37-SNAPSHOT</version>
</dependency>

方式二:Maven 依赖

<dependency>
  <groupId>cn.bestwu</groupId>
  <artifactId>fastdfs-client-java</artifactId>
  <version>1.27</version>
</dependency>

方式三:Spring Boot 集成

<dependency>
  <groupId>com.github.tobato</groupId>
  <artifactId>fastdfs-client</artifactId>
  <version>1.27.2</version>
</dependency>

application.yml 配置:

fdfs:
  connect-timeout: 5000
  so-timeout: 30000
  tracker-list:
    - 10.10.52.38:22122

错误排查

症状根因修复
getStoreStorage returns null检查 Tracker/Storage 状态使用 fdfs_monitor
Connection refusedtracker 地址和防火墙验证地址和防火墙设置
SocketTimeoutException超时值太小增加超时时间
NoSuchMethodError依赖冲突检查依赖版本
404 错误Nginx 反向代理未配置配置 Nginx 访问路径