使用Jena和Maven没有这样的方法错误

时间:2017-12-14 08:15:45

标签: java maven google-places-api jena

我正在开发一个使用Maven和Jena的项目。我正在使用Jena处理一些SPARQL查询。

我执行SPARQL查询的Java类在此错误开始之前一直正常工作。

我是Maven的初学者,所以我不知道如何解决这个问题。甚至可以确定问题在哪里成为一项艰巨的任务。我确切知道程序执行所需的所有依赖项都在那里,但程序拒绝使用jar。

我尝试删除我的.m2 / repository文件夹,但它无效。

PS:这个项目也导入google places api。

控制台错误

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.client.config.RequestConfig$Builder.setContentCompressionEnabled(Z)Lorg/apache/http/client/config/RequestConfig$Builder;
    at org.apache.jena.sparql.engine.http.HttpQuery.contextualizeCompressionSettings(HttpQuery.java:299)
    at org.apache.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:282)
    at org.apache.jena.sparql.engine.http.Service.exec(Service.java:174)
    at org.apache.jena.sparql.engine.main.iterator.QueryIterService.nextStage(QueryIterService.java:55)
    at org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.makeNextStage(QueryIterRepeatApply.java:108)
    at org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:65)
    at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    at org.apache.jena.sparql.engine.iterator.QueryIterDistinct.getInputNextUnseen(QueryIterDistinct.java:104)
    at org.apache.jena.sparql.engine.iterator.QueryIterDistinct.hasNextBinding(QueryIterDistinct.java:70)
    at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
    at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
    at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    at org.apache.jena.sparql.engine.ResultSetStream.hasNext(ResultSetStream.java:74)
    at org.apache.jena.sparql.engine.ResultSetCheckCondition.hasNext(ResultSetCheckCondition.java:55)
    at skpq.SKPQSearch.findFeaturesLGD(SKPQSearch.java:266)
    at skpq.SKPQSearch.main(SKPQSearch.java:60)

发生错误的代码

public TreeSet<SpatialObject> findFeaturesLGD(List<SpatialObject> interestSet, String keywords) {

    List<Resource> featureSet;
    TreeSet<SpatialObject> topK = new TreeSet<>();

    String serviceURI = "http://linkedgeodata.org/sparql";

    for (int a = 0; a < interestSet.size(); a++) {      

        featureSet = new ArrayList<>();

        // Find features within 200 meters (200m = 0.2)

        String queryString = "" + Sparql.addService(USING_GRAPH, serviceURI) + "SELECT DISTINCT ?resource WHERE { <"
                + interestSet.get(a).getURI() + "> <http://geovocab.org/geometry#geometry>  ?point ."
                + "?point <http://www.opengis.net/ont/geosparql#asWKT> ?sourcegeo."
                + "?resource <http://geovocab.org/geometry#geometry> ?loc."
                + "?loc <http://www.opengis.net/ont/geosparql#asWKT> ?location." + "?resource rdfs:label ?nome."
                + "filter(bif:st_intersects( ?location, ?sourcegeo, 0.2)).}"
                + Sparql.addServiceClosing(USING_GRAPH);

        Query query = QueryFactory.create(Sparql.addPrefix().concat(queryString));

        try (QueryExecution qexec = QueryExecutionFactory.create(query, model)) {

            try {
                ResultSet rs = qexec.execSelect();
                //error occurs here
                for (; rs.hasNext();) {

                    QuerySolution rb = rs.nextSolution();

                    RDFNode x = rb.get("resource");

             if (x.isResource()) {                          
                        featureSet.add((Resource) x);                           
                    }
                }
            } finally {
                qexec.close();
            }

我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>LODWEB</groupId>
    <artifactId>LODWEB</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>

        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.22</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.5.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

        <!-- Primefaces -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.0</version>
        </dependency>       <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>cupertino</artifactId>
            <version>1.0.10</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/nz.ac.waikato.cms.weka/weka-stable -->
        <dependency>
            <groupId>nz.ac.waikato.cms.weka</groupId>
            <artifactId>weka-stable</artifactId>
            <version>3.6.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-math3</artifactId>
            <version>3.6.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.prefuse/prefuse -->
        <dependency>
            <groupId>org.prefuse</groupId>
            <artifactId>prefuse</artifactId>
            <version>beta-20071021</version>
        </dependency>       <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>6.0.5</version>
        </dependency>
                <!-- https://mvnrepository.com/artifact/com.github.mpkorstanje/simmetrics-core -->
        <dependency>
            <groupId>com.github.mpkorstanje</groupId>
            <artifactId>simmetrics-core</artifactId>
            <version>4.1.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.jena/jena-tdb -->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-tdb</artifactId>
            <version>3.1.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.jena/jena-iri -->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-iri</artifactId>
            <version>3.1.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.jena/jena-osgi -->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-osgi</artifactId>
            <version>3.1.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.mchange/mchange-commons-java -->
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>mchange-commons-java</artifactId>
            <version>0.2.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.jena/jena-core -->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-core</artifactId>
            <version>3.1.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.jena/jena-arq -->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-arq</artifactId>
            <version>3.1.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.uttesh/exude -->
        <dependency>
            <groupId>com.uttesh</groupId>
            <artifactId>exude</artifactId>
            <version>0.0.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>6.3.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-common</artifactId>
            <version>6.3.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queryparser -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-queryparser</artifactId>
            <version>6.3.0</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queries -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-queries</artifactId>
            <version>6.3.0</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-memory -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-memory</artifactId>
            <version>6.3.0</version>
        </dependency>

        <!-- JSF 2 API -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>primefaces-repository</id>
            <name>Primefaces repository</name>
            <url>http://repository.primefaces.org</url>
        </repository>
    </repositories>



    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

0 个答案:

没有答案