`

开始第一个turbine项目helloworld

阅读更多

文章来源:http://tb.blog.csdn.net/TrackBack.aspx?PostId=1346339
参考文档:http://jakarta.apache.org/turbine/meta/installation.html

参考文档:http://jakarta.apache.org/turbine/meta/getting_started.html


http://www.apache.org/dist/

一、下载Maven 1.0.2

解压maven-1.0.2.zip到硬盘上的某个目录,我把maven解压到C:\JavaSoft\maven\maven-1.0.2,配置环境变量

[Windows]+[Pause/Break]或者右击“我的电脑”,打开系统属性对话框,切换到“高级”面板,点击“环境变量”,为变量PAT

MAVEN_HOME=C:\JavaSoft\maven\maven-1.0.2

PATH=%PATH%;%MAVEN_HOME%/bin

注意:不要贪便宜下载maven-2.x,因为maven2.x和maven1.x完全不一样,而且还没有发布适合turbine的plugin。


二、为maven安装turbine的plugin

运行命令:

maven -DartifactId=maven-turbine-plugin -DgroupId=turbine -Dversion=1.3 plugin:download

注意:turbine官方文档中-Dversion的参数是1.2,为什么要改为1.3呢?原因是1.2支持的是turbine-2.3.1,而1.3支持的是turbine-2.3.2。


三、为meta提供build.properties

在你的用户主目录(Windows系统应该在C:\Documents and Settings\Administrator\)新建一个文本文件,改名为build.properties,编辑其内容为

maven.appserver.home = d:/jakarta-tomcat-5.0.28

(d:/jakarta-tomcat-5.0.28是我的tomcat的解压目录)


四、新建turbine项目helloworld

在一个合适的目录(存放项目代码C:\JavaSoft\turbine-projects),运行命令

C:\JavaSoft\turbine-projects>maven -Dturbine.app.name=helloworld turbine:setup

C:\JavaSoft\turbine-projects>cd helloworld

进入helloword目录,接着再运行命令

C:\JavaSoft\turbine-projects\helloworld>maven turbine:deploy


结果一定会出现

C:\JavaSoft\turbine-projects\helloworld>maven turbine:deploy

 __  __

|  \/  |__ _Apache__ ___

| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~

|_|  |_\__,_|\_/\___|_||_|  v. 1.0.2


???????????????? activation-1.0.2.jar????????

???????????? activation-1.0.2.jar ??????????§°??????

???????????????? mail-1.3.3.jar????????

???????????? mail-1.3.3.jar ??????????§°??????

??????????????????????????????±??????????????¨????????????????????


activation-1.0.2.jar (try downloading from http://java.sun.com/products/javabean

s/glasgow/jaf.html)

mail-1.3.3.jar (try downloading from http://java.sun.com/products/javamail/)


Total time: 7 seconds

Finished at: Mon Oct 23 11:18:07 CST 2006


别担心,之所以出现这样的错误,是因为turbine项目中所依赖的jar包从指定的下载地址中获取不到。而这个所依赖的jar包及其版本号、下载地址则保存在helloworld目录中的project.xml文件中。

根据提示错误信息,打开project.xml:

查找“activation”,修改version为1.1;

查找“mail”,修改version为1.4。


如果还有找不到的jar包,则需要访问<url></url>中所载地址,查看实际提供的版本,如果仍然失败,还可以直接去下载所需要版本的jar包,保存到C:\Documents and Settings\Administrator\.maven\repository目录下对应名称的目录中。需要注意的是jar文件的寻址方式是

C:\Documents and Settings\Administrator\.maven\repository\软件名称\jars\[artifactId]-[ version].[type]

部署成功后,运行D:\jakarta-tomcat-5.0.28\bin目录下的startup.bat启动tomcat服务,在浏览器中输入http://localhost:8080/helloworld,就可以查看你的第一个turbine项目了。

 


五、导入到eclipse

maven eclipse
使用eclipse的工程导入功能,指向helloworld的目录就能够导入helloworld到eclipse了。


其实这样做远远是不够的,因为我们不仅仅需要一个集成编辑环境,更需要的是一个编辑+发布+调试的集成开发环境。没有调试或者不方便调试对我来说是完全不可以接受的,因为那样会严重影响我的工作效率。

所以找到一套调试turbine项目的方法至关重要。下次再记录我摸索的在eclipse中调试turbine的方法

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics