我在使用 Maven 的 Eclipse 中遇到如下错误:
Missing artifact org.eclipse:swt:jar:3.7.
Project 'davmail' is missing required library: '/home/buzz-dee/.m2/repository/org/eclipse/swt/3.7.0/swt-3.7.0.jar'
大多数库都可以找到,如上图所示,但有些没有。但是文件在正确的位置。:
ls ~/.m2/repository/org/eclipse/swt/3.7.0/
swt-3.7.0.jar.lastUpdated swt-3.7.0.pom.lastUpdated
这是部分pom.xml
:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>davmail</groupId>
<artifactId>davmail</artifactId>
<packaging>jar</packaging>
<version>4.6.1</version>
<name>DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway</name>
<organization>
<name>Mickaël Guessant</name>
</organization>
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xwiki</id>
<layout>default</layout>
<url>http://maven.xwiki.org/externals</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-webdav</artifactId>
<version>2.4.3</version>
<exclusions>
<exclusion>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<exclusions>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>swt</artifactId>
<version>3.7.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlcleaner</groupId>
<artifactId>htmlcleaner</artifactId>
<version>2.2</version>
</dependency>
<!-- included in Java 1.6, needed with Java 1.5 -->
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.samba.jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.14</version>
</dependency>
<dependency>
<groupId>net.freeutils.charset</groupId>
<artifactId>jcharset</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.boris.winrun4j</groupId>
<artifactId>winrun4j</artifactId>
<version>0.4.5</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>http://repository.apache.org/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>src/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</project>
有什么问题吗?
最佳答案
根据 this DavMail page , org.eclipse:swt:jar:3.7.0
是一个可选的依赖项。它不在 mavenCentral 中,您可能可以从其他存储库中找到它,但最简单的做法是从您的 pom 中删除该依赖项并使用 -U
或者,正如所讨论的here , 你可以从 here 下载 jar并使用安装命令将其安装到本地 .m2 存储库:
mvn install:install-file -DgroupId=org.eclipse -DartifactId=swt -Dversion=3.7.0 -Dpackaging=jar -Dfile=lib/swt-3.7-win32-x86.jar
请注意,这是一个临时修复,必须在您要构建此项目的每台机器上重复进行。这有点违背了将依赖管理卸载到像 Maven 这样的工具的目的。如果可行的话,我仍然希望将 swt
作为依赖项从您的项目中移除。
关于java - Eclipse/Maven 项目缺少必需的库/缺少 Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29977916/