Maven编译:包不存在 [英] Maven compile: package does not exist
问题描述
我有一个(貌似)简单的maven问题,我不能解决。在我的POM中,我已经指定了一个依赖于openrdf-sesame如下:
I have a (seemingly) simple maven problem I can not solve. In my POM I have specified a dependency to openrdf-sesame like this:
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime</artifactId>
<version>2.7.2</version>
</dependency>
从eclipse运行项目很好,我甚至可以导出一个可运行的jar文件。
不幸的是,我无法通过cmd-line maven正常工作。
要创建一个jar,我已经添加以下到我的pom:
Running the project from eclipse works well, I can even export a runnable jar file. Unfortunately, I cant get it to work properly via cmd-line maven. To build a jar, I have added the following to my pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>foo.bar.Cli</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
编译失败,出现以下错误:
The compilation fails with the following errors:
.../PLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../PLDReducer.java:[27,33] package org.openrdf.sail.nativerdf does not exist
.../LowPLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../Cli.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../SchemaBuilder.java:[30,33] package org.openrdf.sail.nativerdf does not exist
.../RepoQuerier.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../PLDReducer.java:[78,44] cannot find symbol
奇怪的是,一旦我添加编译插件到pom和更新项目设置,eclipse cant似乎编译了。我已经检查了我的存储库,所有的芝麻文件都在那里。
Strangely, as soon as I add the compile plugin to the pom and update project settings, eclipse cant seem to compile anymore as well. I have checked my repository, and all sesame files are in there.
mvn --version给出这个输出:
mvn --version gives this output:
Apache Maven 2.2.1 (rdebian-8)
Java version: 1.6.0_27
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.8.0-25-generic" arch: "amd64" Family: "unix"
我看到它似乎指向一个jre,但我的google搜索表明,我会看到另一个错误如果没有找到编译器本身。
如果有任何帮助,我已在此处粘贴完整的POM。
I see that it seems to point to a jre, but my googling indicated that I would see another error if the compiler itself was not found. I have pasted the complete POM here, if it is of any help.
我失踪了吗?我在我的POM中找不到任何错误。
Is there anything I am missing? I can't find any errors in my POM.
推荐答案
您必须为您的构建添加以下依赖关系:
You have to add the following dependency to your build:
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-rio-api</artifactId>
<version>2.7.2</version>
</dependency>
此外,我建议深入了解关于如何使用lib的文档。
Furthermore i would suggest to take a deep look into the documentation about how to use the lib.
这篇关于Maven编译:包不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!