我在Windows上通过chocolatey安装Redis并在java项目中设置jedis和JOhm。 Redis服务器是Live Redis版本2.6当我想保存像帖子中的Java对象时,我收到了一条错误消息。
java.lang.NoSuchMethodError: redis.clients.jedis.Jedis.sadd(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Long;
at redis.clients.johm.Nest.sadd(Nest.java:168)
at redis.clients.johm.JOhm.save(JOhm.java:220)
at redis.clients.johm.JOhm.save(JOhm.java:146)
这是我的java对象:
/**
*
*/
package com.smsgh.unitysmpp.MessageProcessor;
import java.io.Serializable;
import org.joda.time.DateTime;
import redis.clients.johm.Attribute;
import redis.clients.johm.Id;
import redis.clients.johm.Model;
/**
* @author Arsene Tochemey GANDOTE This class holds the Messages that needs a
* Delivery Receipt
*/
@Model
public class StoredShortMessage implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6185862961624213864L;
@Id
private Integer id;
// session Id
@Attribute
private Long smppSessionId;
// Message Id
@Attribute
private String messageId;
// ESME Account Number#
@Attribute
private Long accountNumber;
// ESME Account Id
@Attribute
private String accountId;
// ESME API Pub Key
@Attribute
private String apiPublicKey;
// Message state
@Attribute
private String messageState;
// Network Error
@Attribute
private String networkErrorCode;
// First 20 Characters of the message
@Attribute
private String mesgFirstLines;
// esme TCP/IP connection
@Attribute
private String ip;
// message submitted datetime
@Attribute
private DateTime submitDate;
// final state date
@Attribute
private DateTime doneDate;
// source address
@Attribute
private byte srcTon;
@Attribute
private byte srcNpi;
@Attribute
private String srcAddr;
// destination address
@Attribute
private byte destTon;
@Attribute
private byte destNpi;
@Attribute
private String destAddr;
// delivery state
@Attribute
private char dlrState;
/**
*
*/
public StoredShortMessage() {
}
/**
* @return the smppSessionId
*/
public Long getSmppSessionId() {
return smppSessionId;
}
/**
* @param smppSessionId
* the smppSessionId to set
*/
public void setSmppSessionId(Long smppSessionId) {
this.smppSessionId = smppSessionId;
}
/**
* @return the messageId
*/
public String getMessageId() {
return messageId;
}
/**
* @param messageId
* the messageId to set
*/
public void setMessageId(String messageId) {
this.messageId = messageId;
}
/**
* @return the accountNumber
*/
public Long getAccountNumber() {
return accountNumber;
}
/**
* @param accountNumber
* the accountNumber to set
*/
public void setAccountNumber(Long accountNumber) {
this.accountNumber = accountNumber;
}
/**
* @return the accountId
*/
public String getAccountId() {
return accountId;
}
/**
* @param accountId
* the accountId to set
*/
public void setAccountId(String accountId) {
this.accountId = accountId;
}
/**
* @return the apiPublicKey
*/
public String getApiPublicKey() {
return apiPublicKey;
}
/**
* @param apiPublicKey
* the apiPublicKey to set
*/
public void setApiPublicKey(String apiPublicKey) {
this.apiPublicKey = apiPublicKey;
}
/**
* @return the messageState
*/
public String getMessageState() {
return messageState;
}
/**
* @param messageState
* the messageState to set
*/
public void setMessageState(String messageState) {
this.messageState = messageState;
}
/**
* @return the networkErrorCode
*/
public String getNetworkErrorCode() {
return networkErrorCode;
}
/**
* @param networkErrorCode
* the networkErrorCode to set
*/
public void setNetworkErrorCode(String networkErrorCode) {
this.networkErrorCode = networkErrorCode;
}
/**
* @return the mesgFirstLines
*/
public String getMesgFirstLines() {
return mesgFirstLines;
}
/**
* @param mesgFirstLines
* the mesgFirstLines to set
*/
public void setMesgFirstLines(String mesgFirstLines) {
this.mesgFirstLines = mesgFirstLines;
}
/**
* @return the ip
*/
public String getIp() {
return ip;
}
/**
* @param ip
* the ip to set
*/
public void setIp(String ip) {
this.ip = ip;
}
/**
* @return the submitDate
*/
public DateTime getSubmitDate() {
return submitDate;
}
/**
* @param submitDate
* the submitDate to set
*/
public void setSubmitDate(DateTime submitDate) {
this.submitDate = submitDate;
}
/**
* @return the doneDate
*/
public DateTime getDoneDate() {
return doneDate;
}
/**
* @param doneDate
* the doneDate to set
*/
public void setDoneDate(DateTime doneDate) {
this.doneDate = doneDate;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/**
* @return the srcTon
*/
public byte getSrcTon() {
return srcTon;
}
/**
* @param srcTon
* the srcTon to set
*/
public void setSrcTon(byte srcTon) {
this.srcTon = srcTon;
}
/**
* @return the srcNpi
*/
public byte getSrcNpi() {
return srcNpi;
}
/**
* @param srcNpi
* the srcNpi to set
*/
public void setSrcNpi(byte srcNpi) {
this.srcNpi = srcNpi;
}
/**
* @return the srcAddr
*/
public String getSrcAddr() {
return srcAddr;
}
/**
* @param srcAddr
* the srcAddr to set
*/
public void setSrcAddr(String srcAddr) {
this.srcAddr = srcAddr;
}
/**
* @return the destTon
*/
public byte getDestTon() {
return destTon;
}
/**
* @param destTon
* the destTon to set
*/
public void setDestTon(byte destTon) {
this.destTon = destTon;
}
/**
* @return the destNpi
*/
public byte getDestNpi() {
return destNpi;
}
/**
* @param destNpi
* the destNpi to set
*/
public void setDestNpi(byte destNpi) {
this.destNpi = destNpi;
}
/**
* @return the destAddr
*/
public String getDestAddr() {
return destAddr;
}
/**
* @param destAddr
* the destAddr to set
*/
public void setDestAddr(String destAddr) {
this.destAddr = destAddr;
}
/**
* @return the dlrState
*/
public char getDlrState() {
return dlrState;
}
/**
* @param dlrState
* the dlrState to set
*/
public void setDlrState(char dlrState) {
this.dlrState = dlrState;
}
}
有人能告诉我可能是什么错误吗?感谢
答案 0 :(得分:1)
要解决我必须下载源代码并使用它。我认为我下载的jar文件中有一个错误。
答案 1 :(得分:0)
从
下载项目来源https://github.com/xetorthio/johm
编辑pom.xml
将Jedis版本从1.5.1更改为2.4.2或更新
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.4.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
编译项目并构建jar,在项目中使用这个新jar