我从Juno Eclipse切换到Kepler并导入了我的Maven项目。但是,“Maven Dependencies”没有显示在Project-Properties-Java Build Path-Libraries下,因此我无法编译我的项目。在Maven Repositories视图中,我可以看到Local Repositories下的所有依赖jar文件。我可以手动添加外部Jar文件,但必须有正确的方法来动态加载它们。我可以从Eclipse成功运行“maven install”。我已经尝试了这个论坛的所有建议,例如 - 运行Maven-Update Project,从Workspace项目中选中未经检查的Maven-Resolve依赖项,Window-Preferences-检查“在启动时下载存储库索引更新”和“在启动时更新Maven项目”。 Kepler Eclipse有点奇怪。我错过了什么?
这是我的pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd“>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.xxx</groupId>
<artifactId>actives</artifactId>
<version>3.1.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<id>jar-with-dependencies</id>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>com.xxx.xxx.xxx.xxx.XXX</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <!-- Include all depedencies in build -->
</descriptorRefs>
<!--<appendAssemblyId>false</appendAssemblyId> -->
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.3</version>
</extension>
</extensions>
</build>
<properties>
<root>.</root>
<xxx.releases>http://xxx.xxx.local/mave</xxx.releases>
<xxxx.releases>http://xxx.xxx.local/xxx/releases</xxx.releases>
<xxx.snapshots>http://xxx.associatesys.local/xxx/snapshots</xxx.snapshots>
<xxx.releases.distribution>scp://xxx.associatesys.local/../../../srv/www/release/xxxx/releases</xxx.releases.distribution>
<xxx.snapshots.distribution>scp://xxx.xxx.local/../../../srv/www/release/xxx/snapshots</xxx.snapshots.distribution>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>central</id>
<name>central</name>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-central</id>
<name>XXXCentral</name>
<url>http://xxx.xxx.local/maven2/central</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-releases</id>
<name>Internal ReleasesRepository</name>
<url>${xxx.releases}</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-releases</id>
<name>XXXReleases Repository</name>
<url>${xxx.releases}</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-snapshots</id>
<name>XXXX Snapshots Repository</name>
<url>${xxx.snapshots}</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:30</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>sqljdbc</groupId>
<artifactId>sqljdbc</artifactId>
<version>4</version>
</dependency>
<dependency>
<groupId>xxxx</groupId>
<artifactId>xxx-xxx</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.xxx.xxx.client</groupId>
<artifactId>xxx-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.xxx.xxx.xxx</groupId>
<artifactId>xxx-xxx</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.xxx.xxx.common</groupId>
<artifactId>xxx-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>xxx-releases</id>
<name>XXXXReleases Repository</name>
<url>${xxx.releases.distribution}</url>
</repository>
<snapshotRepository>
<id>xxx-snapshots</id>
<name>XXXSnapshots Repository</name>
<url>${xxx.snapshots.distribution}</url>
</snapshotRepository>
</distributionManagement>
更新:我通过复制并粘贴来自Eclipse(Kepler)中另一个没有问题的Maven项目的.classpath和.project文件解决了这个问题。我对这两个文件进行了微调。我比较了pom.xml文件,发现没有任何差异会阻止Eclipse创建我的Maven项目。它不是一个理想的解决方案,但它现在有效,没有时间解决Eclipse“神秘”。感谢以下评论,他们指出了我正确的方向,并帮助更好地理解问题。