当我尝试在与maven-shade-plugin一起打包的独立Java应用程序中使用Sesame Rio时,我得到了
Exception in thread "main" org.openrdf.rio.UnsupportedRDFormatException: Did not recognise RDF format object N-Triples (mimeTypes=application/n-triples, text/plain; ext=nt)
at org.openrdf.rio.Rio.lambda$unsupportedFormat$0(Rio.java:630)
at org.openrdf.rio.Rio$$Lambda$1/736709391.get(Unknown Source)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.openrdf.rio.Rio.createParser(Rio.java:119)
at org.openrdf.rio.Rio.createParser(Rio.java:137)
at org.openrdf.repository.util.RDFLoader.loadInputStreamOrReader(RDFLoader.java:318)
at org.openrdf.repository.util.RDFLoader.load(RDFLoader.java:222)
at org.openrdf.repository.util.RDFLoader.load(RDFLoader.java:105)
at org.openrdf.repository.base.AbstractRepositoryConnection.add(AbstractRepositoryConnection.java:255)
从Eclipse运行应用程序成功。我该如何解决这个问题?
答案 0 :(得分:2)
Rio中的RDF格式处理程序实现为services,因此服务描述符必须包含在着色JAR中。这是通过ServicesResourceTransformer
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
更多信息: