我正在使用Eclipse和Java。我已经设置了jena库,并使用该库完成了我的第一个RDF语句,但是我得到了警告,但我不知道这到底意味着什么。
这是代码:
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
public class Main {
public static void main(String[] args) {
Model m = ModelFactory.createDefaultModel();
String NS = "http://www.example.org/rdf/";
Resource r = m.createResource(NS + "r");
Property p = m.createProperty(NS + "p");
r.addProperty(p, "hello world", XSDDatatype.XSDstring);
m.write(System.out, "Turtle");
}
}
这是输出:
log4j:WARN No appenders could be found for logger (org.apache.jena.riot.stream.JenaIOEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
<http://www.example.org/rdf/r>
<http://www.example.org/rdf/p> "hello world"^^<http://www.w3.org/2001/XMLSchema#string> .
因此代码可以编译并正常工作,但是我不知道该怎么办。
我该如何摆脱呢?
最佳答案
Ariel提供的答案有问题。实际上,当我们编写代码Log.setLog4j("jena-log4j.properties");
时,会出现以下错误:
The method setLog4j(String) is undefined for the type Log
但您可以在此处找到更好的答案:
Configure Eclipse for Log4j
您只需要在放置主类的文件夹中复制文件
jena-log4j.properties
。即具有主要功能的类。然后,您需要将文件重命名为
log4j.properties
。我在Eclipse中完成了工作,并为我工作。