【问题标题】:Building AliBaba java example搭建阿里巴巴java示例
【发布时间】:2013-05-14 13:25:35
【问题描述】:

晚上好,

我是 Java Persistence API 的新手,我想测试一下阿里巴巴,看看它能做什么。 AliBaba website。我读了the exemple given here 的一部分。我有整个阿里巴巴项目和两个示例文件,我对示例进行了一些修改。

//Document.java
package org.openrdf.example;

import org.openrdf.annotations.Iri;

@Iri(Document.NS + "Document")
public class Document {
public static final String NS = "http://meta.leighnet.ca/rdf/2009/gs#";

@Iri(NS + "title") String title;

public String getTitle() {
    return title;
}
public void setTitle(String title) {
    this.title = title;
}
}

还有我的其他文件:

//my Main with many imports
public class Main {
public static void main(String[] args) throws java.lang.IllegalAccessException {
    // create a Document
    Document doc = new Document();
    // give it a title
    doc.setTitle("Getting Started");
    System.out.println("Title of the new document: "+doc.getTitle());
    
    // add a Document to the repository
    ObjectConnection con = repository.getConnection();
    // the problem is here

我的问题出在这一行:

ObjectConnection con = repository.getConnection();

我没有“存储库”的声明。 但对象类型出现错误。

感谢您的帮助,我希望我的文字可以理解,因为这是我在这里的第一篇文章。

【问题讨论】:

  • 用户文档在他们的网站上:link
  • 谢谢你提供这个链接,我不知道我怎么没看到它。很有帮助。

标签: java rdf sesame


【解决方案1】:

您可以像这样创建内存中的 Sesame 存储库:

// create a repository
Repository store = new SailRepository(new MemoryStore());
store.initialize();

// wrap in an object repository
ObjectRepositoryFactory factory = new ObjectRepositoryFactory();
ObjectRepository repository = factory.createRepository(store);

【讨论】:

  • 感谢您的指示,我需要创建一个存储库。事实上,在我第一次阅读的文档中,开发人员假设您了解存储库的整个概念。有了之前链接的文档和你的例子,就更容易理解了。