RabbitMQ Java客户端-Java依赖关系(标准库?) [英] RabbitMQ Java Client - Java Dependencies (standard libraries?)
问题描述
我需要将RabbitMQ与运行在Java上的另一个系统集成在一起.因此,我转到了官方网站,下载了该程序包并将其复制到我的类路径中.然后,我遵循了基础教程,并且我验证了导入外部库的作用.
I need to integrate RabbitMQ with another system that runs on Java. So I went to the official website, downloaded the package and copied it to my classpath. Then I followed the basic tutorial, and I verified that importing external libraries work.
我现在面对的问题对于Java开发人员来说可能很容易解决:为了使以下代码正常工作,我必须导入哪些标准Java库?
The problem I face now is probably very easy to solve for a Java developer: which standard Java libraries do I have to import to make the following code work?
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;
...
ConnectionFactory factory = new ConnectionFactory();
没有遇到这样的导入错误:
without running into import errors like this:
Line 51, Column 18: No applicable constructor/method found for actual parameters "java.lang.String";
candidates are: "void com.rabbitmq.client.ConnectionFactory.setPort(int)"
我尝试了类似的方法,但是我不知道它在Java中是如何工作的,所以我想澄清一下.例如,何时应使用星号?
I tried things like these, but I have no idea how that works in Java, so I would like to have some clarification. For example, when should I use an asterisk?
import java.lang.String;
import java.lang.String.*;
顺便说一句,我尝试将RabbitMQ与之集成的系统是Pentaho Data Integration(又名Kettle).
By the way, the system I am trying to integrate RabbitMQ with is Pentaho Data Integration (a.k.a. Kettle).
推荐答案
首先,摆脱您的java.lang
导入.
Second, call setPort
with an int
and not a String
as described in the API.
这篇关于RabbitMQ Java客户端-Java依赖关系(标准库?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!