我在Java Spring Boot应用程序中从Redis提取数据时遇到问题
我创建了以下课程
public interface ArticlesRepository extends CrudRepository<Articles, String> {
}
@RedisHash("Articles")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Articles implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private long timestamp;
private ArticlesData articles;
}
@RedisHash("ArticlesData")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ArticlesData implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String continuation;
private ArrayList<ArticleInfo> articles;
}
@RedisHash("ArticleInfo")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ArticleInfo implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String title;
private String linkToArticle;
private long publishedDate;
}
当我保存Articles实例时,一切似乎都可以正常工作
Articles articles = new Articles(id, timestamp, articlesData);
articlesRepository.save(articles);
但是,当我尝试从Redis检索该对象时,发生了奇怪的事情
Articles articles = articlesRepository.findOne(redisArticleId);
正确设置了对象中的所有字段(id和时间戳),但ArticlesData始终返回null。
System.out.println(articles.getId()); ==> WAPCO:
System.out.println(articles.getTimestamp()); ==> 1530049920
System.out.println(articles.getArticles()); ==> null
有人对我可能做错了什么有什么想法?