如何在Talend Open Studio上设置类路径

问题描述 投票:1回答:1

我创建了一个依赖于Apache HTTP Components的例程,所以我下载了jar文件并将这些文件添加到Build Path中。

我在Java \ Build Path下设置了类路径变量和用户库,但它仍然不起作用。

我的代码编译没有任何错误,但它无法运行以下异常:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/RedirectStrategy
    at routines.downloadXls.start(downloadXls.java:10)
[...]

这段Java代码如下,它与Eclipse一起运行:

private CloseableHttpClient createHttpClient() {
        HttpClientBuilder builder = HttpClientBuilder.create();
        httpCtx.setAttribute(HttpClientContext.COOKIE_STORE, store);
        return builder.setRedirectStrategy(LaxRedirectStrategy.INSTANCE).build();
    }

我已经看过一个similar question on talend community,但它没有帮助我。

请问有什么建议吗?

谢谢

java talend apache-httpcomponents
1个回答
2
投票

您需要使用tLibraryLoad组件(每个jar一个)在Talend作业中添加jar。

tLibraryLoad
        |
OnSubjobOk
        |
Code using apache components

在构建作业时,jar将与它捆绑在一起并添加到类路径中(在.bat和.sh启动器中)。 我注意到你在代码中设置了一个cookie,也许如果你提供更多关于你的需求的细节,我可以推荐一个使用专用Talend组件的解决方案,因为最好尽可能使用本机组件(或者你可以问一个单独的问题)。

© www.soinside.com 2019 - 2024. All rights reserved.