我正在使用一个基于IBM MQ的jar来浏览队列中的特定消息。在通过Maven构建此项目时,我遇到了这个问题package com.ibm.mq不存在。
我已经在 build path 和 lib 文件夹中添加了这个jar。
我编写这个逻辑的控制器类没有显示任何由于 * com.ibm.mq * 导入而导致的编译错误。但是我在通过maven构建时遇到了这个错误!
应该做点什么吗?
请帮帮我
MQ控制器:
package main.java.controller;
import java.io.*;
import java.util.Properties;
import java.util.Calendar;
import com.ibm.mq.*;
public class MQController {
private static String myQmgr = "QSOA";
private static String myQueue = "MQ.EVENTS.POLICY.DUMMY";
public MQController() {
myQmgr = System.getProperty("qm");
myQueue = System.getProperty("q");
try {
Properties props = new Properties(System.getProperties());
props.load(new BufferedInputStream(new FileInputStream("MQController.properties")));
System.setProperties(props);
} catch (Exception e) {
System.out.println("Error getting MQController.properties: " + e.getMessage());
System.err.println(e);
}
/*if (myQmgr == null) {myQmgr = System.getProperty("qm");}
if (myQueue == null) {myQueue = System.getProperty("q");}*/
}
public MQController(String[] args) {
this(); /* call the default constructor */
for( int i=0; i<args.length; i++ ) {
String arg = args[i].toLowerCase();
if( arg.equals("-qm") ) {
if ( i+1<args.length ) {
myQmgr = args[++i];
} else {
System.out.println("didn't specify qmgr, exiting");
return;
}
} else if( arg.equals("-q") ) {
if ( i+1<args.length ) {
myQueue = args[++i];
} else {
System.out.println("didn't specify queue, exiting");
return;
}
} else {
System.out.println( "Unknown argument: " + arg );
}
}
}
public void myBrowser() {
MQQueueManager qMgr = null;
MQQueue browseQueue = null;
int j = 0; /* used as a message counter */
System.out.println("\n MQController.java - starts here");
System.out.println("**************************");
MQException.log = null; /* don't print out any exceptions */
try {
qMgr = new MQQueueManager(myQmgr);
int openOptions = MQC.MQOO_BROWSE;
browseQueue = qMgr.accessQueue(myQueue, openOptions, null, null, null);
System.out.println("\n OPEN - '" + myQueue + "'\n\n");
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = gmo.options + MQC.MQGMO_BROWSE_NEXT;
MQMessage myMessage = new MQMessage();
while (true) {
myMessage.clearMessage();
myMessage.correlationId = MQC.MQCI_NONE;
myMessage.messageId = MQC.MQMI_NONE;
browseQueue.get(myMessage, gmo);
j = j + 1;
System.out.println(" GET of message number " + j);
System.out.println("****Message descriptor****\n");
System.out.println(" StrucId : 'MD '"
+ " Version : " + myMessage.getVersion());
System.out.println(" Report : " + myMessage.report
+ " MsgType : " + myMessage.messageType);
System.out.println(" Expiry : " + myMessage.expiry
+ " Feedback : " + myMessage.feedback);
System.out.println(" Encoding : " + myMessage.encoding
+ " CodedCharSetId : " + myMessage.characterSet);
System.out.println(" Format : '" + myMessage.format + "'");
System.out.println(" Priority : " + myMessage.priority
+ " Persistence : " + myMessage.persistence);
System.out.print(" MsgId : ");
System.out.print(" CorrelId : ");
System.out.println(" BackoutCount : " + myMessage.backoutCount);
System.out.println(" ReplyToQ : '"
+ myMessage.replyToQueueName + "'");
System.out.println(" ReplyToQMgr : '"
+ myMessage.replyToQueueManagerName + "'");
System.out.println(" ** Identity Context");
System.out.println(" UserIdentifier : '" + myMessage.userId + "'");
System.out.println(" Accounting Token :");
System.out.print(" ");
System.out.println(" ApplIdentityData : '"
+ myMessage.applicationIdData + "'");
System.out.println(" ** Origin Context");
System.out.println(" PutApplType : '"
+ myMessage.putApplicationType + "'");
System.out.println(" PutApplName : '"
+ myMessage.putApplicationName + "'");
System.out.print(" PutDate : '");
System.out.print(myMessage.putDateTime.get(Calendar.YEAR));
int myMonth = myMessage.putDateTime.get(Calendar.MONTH) + 1;
if (myMonth < 10) {System.out.print("0");}
System.out.print(myMonth);
int myDay = myMessage.putDateTime.get(Calendar.DAY_OF_MONTH);
if (myDay < 10) {System.out.print("0");}
System.out.print(myDay);
System.out.print("' ");
System.out.print("PutTime : '");
int myHour = myMessage.putDateTime.get(Calendar.HOUR_OF_DAY);
if (myHour < 10) { System.out.print("0"); }
System.out.print(myHour);
int myMinute = myMessage.putDateTime.get(Calendar.MINUTE);
if (myMinute < 10) { System.out.print("0"); }
System.out.print(myMinute);
int mySecond = myMessage.putDateTime.get(Calendar.SECOND);
if (mySecond < 10) { System.out.print("0"); }
System.out.print(mySecond);
int myMsec = myMessage.putDateTime.get(Calendar.MILLISECOND);
myMsec = myMsec/10;
if (myMsec < 10) { System.out.print("0"); }
System.out.print(myMsec);
System.out.println("'");
System.out.println(" ApplOriginData : '"
+ myMessage.applicationOriginData + "'");
System.out.println();
System.out.print(" GroupId : ");
System.out.println(" MsgSeqNumber : '"
+ myMessage.messageSequenceNumber + "'");
System.out.println(" Offset : '" + myMessage.offset + "'");
System.out.println(" MsgFlags : '"
+ myMessage.messageFlags + "'");
System.out.println(" OriginalLength : '"
+ myMessage.originalLength + "'");
System.out.println();
System.out.println("**** Message ****");
System.out.println();
System.out.println(" length - " + myMessage.getMessageLength()
+ " bytes\n");
System.out.println();
System.out.println();
}
} catch (MQException ex) {
if (ex.reasonCode == MQException.MQRC_NO_MSG_AVAILABLE) {
System.out.println(" No more messages");
} else {
System.out.println("MQ error: Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
}
} catch (java.io.IOException ex) {
System.out.println("An IO error occurred: " + ex);
}
try {
browseQueue.close();
System.out.println(" CLOSE of queue");
qMgr.disconnect();
System.out.println(" DISCONNECT from queue manager");
} catch (MQException ex) {
System.out.println("MQ error: Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
}
System.out.println("**************************");
System.out.println("MQController.java finished");
}
public static void main( String[] args ) {
MQController app = new MQController(args);
if ( (myQmgr==null)
|| (myQueue==null) ) {
System.out.println("Usage:");
System.out.println("java MQController -qm ... -q ...");
System.out.println("where -qm is the queue manager name");
System.out.println(" -q is the queue name");
} else {
app.myBrowser();
}
}
}
字符串
屏幕截图:x1c 0d1x
2条答案
按热度按时间ghhaqwfi1#
您可以使用此依赖项(https://mvnrepository.com/artifact/com.ibm.mq/com.ibm.mq.allclient/9.3.4.0)。
zsbz8rwp2#
如果你有Maven,为什么要使用Eclipse Java Build Path?
相反,您应该将此依赖项添加到
pom.xml
中:字符串
编辑
**此依赖关系似乎是指一个不存在的依赖关系。**建议您参考以下问题: