最近项目在慢慢转型到Docker环境,在测试过程中发现原本很稳定的上传文件到FTP服务器的地方报错了,主要报错信息如下:
FTP response 421 received.Server closed connection1
查找解决方法之后发现在上传FTP时,只需要将FTP操作改为被动模式即可(ftpClient.enterLocalPassiveMode();),修改之后重新部署测试上传文件到FTP正常。
示例如下:
@Component public class FtpUtils { private static Logger logger = LoggerFactory.getLogger(UserLoginController.class); @Autowired private FtpConfig ftpConfig; public FTPClient ftpClient = null; /** * 初始化链接文件 */ public void initFtpClient() { ftpClient = new FTPClient(); ftpClient.setRemoteVerificationEnabled(
1234567891011121314151617