2

我正在使用通过巧克力安装在 Windows 上的 Redis,并在 Java 项目中设置 jedis 和 JOhm。Redis 服务器是实时的 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;
    }
}

有人可以告诉我可能是什么错误吗?谢谢

4

2 回答 2

1

为了解决我必须下载源代码并使用它。我认为我下载的 jar 文件中存在错误。

于 2013-03-05T14:11:05.080 回答
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

于 2014-05-02T14:11:10.307 回答