尝试将 Java 消息服务 (JMS) API 与服务总线和 AMQP 一起使用

Trying to use Java Message Service (JMS) API with Service Bus and AMQP

我正在尝试执行此 example program,但我收到以下 class 未找到异常:

javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at filternet.SimpleSenderReceiver.<init>(SimpleSenderReceiver.java:30)
    at filternet.SimpleSenderReceiver.main(SimpleSenderReceiver.java:60)
Caused by: java.lang.ClassNotFoundException: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory*

我在我的 pom 文件中包含了以下依赖项:

 <dependency> <groupId>org.apache.qpid</groupId>
 <artifactId>qpid-jms-client</artifactId> </dependency>

但是我在本地 Maven 存储库中找不到 PropertiesFileInitialContextFactory class 文件和任何 jndi 目录。

通过单独下载jar并根据此文档将它们安装到Maven存储库中解决:

How to add local jar files in maven project?

然后将 jar 安装中的 pom 定义添加到项目的 pom.xml 文件中。