【发布时间】:2014-06-18 20:48:43
【问题描述】:
我是使用 Maven 和 Eclipse 的新手,我正在关注 this 链接。
下面是我工作区中的 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.HelloWorld</groupId>
<artifactId>SpringHelloWorld</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpringHelloWorld Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>3.0.5.RELEASE</spring.version>
<jdk.version>1.6</jdk.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>SpringHelloWorld</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
为了添加所需的 jar,我从命令提示符运行以下命令:
mvn eclipse:eclipse -Dwtpversion=2.0
我在控制台中收到“BUILD SUCCESS”消息。但是当我在 Eclipse IDE 中刷新项目时,我可以看到所有库都丢失了,并且这些 jar 的路径不存在。
例如
Description Resource Path Location Type
Project 'SpringHelloWorld' is missing required library: 'C:\Users\username\.m2\repository\org\springframework\spring-aop\3.0.5.RELEASE\spring-aop-3.0.5.RELEASE.jar' SpringHelloWorld Build path Build Path Problem
对于这个错误,当我手动检查时,我在org 文件夹内看不到任何名为springframework 的文件夹,因此jar 丢失并且在Eclipse IDE 中显示错误。
我尝试多次运行命令mvn eclipse:eclipse -Dwtpversion=2.0,但没有用。
请告知如何解决这个问题。
编辑
以下是 Eclipse 安装的快照:
编辑 2
当我在 Eclipse IDE 中的项目上 Right Click 时,我没有得到 Maven 选项。因此,当我在main 文件夹, I am not able toUpdate Project Configuration` 下创建java 文件夹时,如here 所述。请指教
【问题讨论】:
-
你为 Eclipse 安装了 maven 集成工具(m2eclipse)吗?
-
@MironBalcerzak 我已经在上面的帖子中添加了快照,如果有什么遗漏,请检查并提出建议。
-
你真的在使用 Eclispe 3.7.x 吗?
-
@khmarbaise 是的。文件 .eclipseproduct 给了我这个:
name=Eclipse Platform id=org.eclipse.platform version=3.7.0 -
单击项目图标后,您是否尝试在其中一个选项中“转换为 maven 项目”?
标签: java eclipse spring maven spring-mvc