2013-03-04 60 views
2

我在Windows上通過巧克力安裝Redis,並在java項目中安裝jedis和JOhm。 Redis服務器是Redis現場版本2.6當我想保存一個Java對象,就像在帖子中的那樣,我收到一條錯誤消息。Jedis和JOhm錯誤

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; 
    } 
} 

有人能告訴我什麼可以是錯誤?謝謝

回答

1

解決我必須下載源代碼並使用它。我認爲我下載的jar文件存在一個錯誤。

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> 

編譯項目並構建j ar,在您的項目中使用這個新罐子