最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

groovy - Apache Nifi ExecuteGroovyScript: use FTP client inside script - Stack Overflow

programmeradmin4浏览0评论

I'm trying to realize inside ExecuteGroovyScript something like:

  import .apachemons.ftp.FTPClient
  import .apachemons.ftp.FTP

  def ftpClient = new FTPClient()

  try{
    ftpClient.connect("host")
    // some logic
  } finally {
    if (ftpClient.isConnected()) {
        try {
            ftpClient.logout()
            ftpClient.disconnect()
        } catch (IOException e) {
            // 
        }
    }
 }

But I receive the exception: Unable to resolve class : .apachemons.ftp.FTPClient

May be there no way to realize FTP connection inside ExecuteGroovyScript ?

I'm trying to realize inside ExecuteGroovyScript something like:

  import .apachemons.ftp.FTPClient
  import .apachemons.ftp.FTP

  def ftpClient = new FTPClient()

  try{
    ftpClient.connect("host")
    // some logic
  } finally {
    if (ftpClient.isConnected()) {
        try {
            ftpClient.logout()
            ftpClient.disconnect()
        } catch (IOException e) {
            // 
        }
    }
 }

But I receive the exception: Unable to resolve class : .apachemons.ftp.FTPClient

May be there no way to realize FTP connection inside ExecuteGroovyScript ?

Share Improve this question asked Mar 25 at 14:26 JellyJelly 1,3325 gold badges26 silver badges58 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The nifi-scripting-nar doesn't include commons-net. You can use @Grab to add the dependency, see my blog post for an example of how to do this.

发布评论

评论列表(0)

  1. 暂无评论