[英]How to set classpath on Talend Open Studio
I've created a routine that depends on Apache HTTP Components , so I've downloaded the jar files and added those files to the Build Path. 我创建了一个依赖于Apache HTTP Components的例程,因此我下载了jar文件并将这些文件添加到Build Path中。
I've set up both Classpath Variables and User Libraries under Java\\Build Path , but it still doesn't work. 我已经在Java \\ Build Path下设置了Classpath变量和User Libraries ,但是仍然无法使用。
My code compile without any errors, but it fails to run with the following exception: 我的代码编译没有任何错误,但是由于以下异常而无法运行:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/RedirectStrategy
at routines.downloadXls.start(downloadXls.java:10)
[...]
The piece of Java code is the following, it runs with Eclipse: 以下是Java代码,它与Eclipse一起运行:
private CloseableHttpClient createHttpClient() {
HttpClientBuilder builder = HttpClientBuilder.create();
httpCtx.setAttribute(HttpClientContext.COOKIE_STORE, store);
return builder.setRedirectStrategy(LaxRedirectStrategy.INSTANCE).build();
}
I've already seen a similar question on talend community , but it didn't help me. 我已经在talend社区上看到了类似的问题 ,但这并没有帮助我。
Any suggestion, please? 有什么建议吗?
Thanks 谢谢
You need to add your jar(s) in your Talend job using tLibraryLoad
component (one per jar). 您需要使用
tLibraryLoad
组件(每个jar一个)在您的Talend作业中tLibraryLoad
jar。
tLibraryLoad
|
OnSubjobOk
|
Code using apache components
When you build your job, the jars will be bundled with it and added to your classpath (in .bat and .sh launchers). 在创建作业时,罐子将与它捆绑在一起并添加到您的类路径中(在.bat和.sh启动器中)。
I noticed you're setting a cookie in your code, maybe if you give more detail about your requirement I can recommend a solution using dedicated Talend components, as it's best to use native components whenever possible (or you can ask a separate question). 我注意到您在代码中设置了cookie,也许如果您提供有关需求的更多信息,我可以推荐使用专用Talend组件的解决方案,因为最好是尽可能使用本机组件(或者您可以提出一个单独的问题)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.