【发布时间】:2012-03-28 07:38:22
【问题描述】:
我正在尝试使用 maven(struts2 空白原型)开始一个新的 struts 2 项目 下面的代码运行并生成项目及其 pom.xml
D:\Dev\IndigoWS>mvn archetype:generate -B DgroupId=com.proj.core -DartifactId=MyStruts2Blank -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-ar
chetype-blank -DarchetypeVersion=2.2.1
使用来自终端的以下堆栈跟踪。
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Batch mode
[INFO] Archetype repository missing. Using the one from [org.apache.struts:strut
s2-archetype-blank:2.2.3] found in catalog remote
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
但每当我尝试使用命令将其转换为 Eclipse 项目时
mvn eclipse:eclipse -Dwtpversion=1.5
我遇到了下面的致命错误
D:\Dev\MyWorkspace>cd MyStruts2Blank
D:\Dev\MyWorkspace\MyStruts2Blank>mvn eclipse:eclipse -Dwtpversion=1.5
[INFO] 正在扫描项目... [信息] - - - - - - - - - - - - - - - - - - - - - - - - ---------------------------------- [错误] 致命错误
[信息] - - - - - - - - - - - - - - - - - - - - - - - - -------------------------------------------------- ---------------------- [INFO] 构建 POM 时出错(可能不是此项目的 POM)。项目 ID:com.proj.core:MyStruts2Blank POM 位置: D:\Dev\MyWorkspace\MyStruts2Blank\pom.xml
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.royj.core</groupId>
<artifactId>MyStruts2Blank</artifactId>
<version>${project.version}</version>
<packaging>war</packaging>
<name>Struts 2 Blank Webapp</name>
<properties>
<struts2.version>${project.version}</struts2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>${struts2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.21</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<scanTargets>
<scanTarget>src/main/webapp/WEB-INF</scanTarget>
<scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget>
<scanTarget>src/main/resources/struts.xml</scanTarget>
<scanTarget>src/main/resources/example.xml</scanTarget>
</scanTargets>
</configuration>
</plugin>
</plugins>
</build>
</project>
和 maven 版本
Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
Java version: 1.6.0_24
Java home: C:\Program Files\Java\jdk1.6.0_24\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
我需要做些什么来解决这个问题并成功生成一个 struts 2 空白原型。我可以使用 maven 成功地为 struts 2 创建一个入门原型,但对于空白原型没有成功。空白原型不再可用吗?顺便说一句,我正在使用 Eclipse Indigo 版本:Indigo,发布版本 ID:20110615-0604 在此先感谢各位。
【问题讨论】:
-
哪个eclipse版本,哪个Maven版本?你可以发布 POM 吗?
-
@UmeshAwasthi 和我已经编辑了我的问题,并通过我使用 Eclipse Indigo 版本的方式包含了 pom.xml:Indigo Release Build id:20110615-0604
-
@khmarbaise 我已经编辑了我的问题,并通过我使用 Eclipse Indigo 版本的方式包含了 pom.xml:Indigo Release Build id:20110615-0604
-
@royjavelosa:正如答案中建议的那样,首先缺少
project.version,我建议您使用maven独立版本