最近公司有一個項目要用stripes + spring(Spring JDBC)開發,用maven構建,linux(Ubuntu)系統,web服務器用websphere 6.0。
今天開始,深入淺出學習stripes,看看它優越於struts1的緣由究竟在哪裡。
備忘:開發之前,請保證機器上已經安裝並且正確配置了java開發環境(jdk 5以上),maven等。
1、下載stripes的maven外掛程式,stripes-archetype-quickstart-1.0.jar Download
2、將stripes-archetype-quickstart-1.0.jar安裝到maven本地倉庫。
mvn install:install-file -Dfile=stripes-archetype-quickstart-1.0.jar -DgroupId=net.sourceforge -DartifactId=stripes-archetype-quickstart -Dversion=1.0 -Dpackaging=jar
3、使用stripes外掛程式建立第一個stripes工程
mvn archetype:generate -DarchetypeArtifactId=stripes-archetype-quickstart -DarchetypeGroupId=net.sourceforge -DarchetypeVersion=1.0 -DgroupId=tutorial -DartifactId=HelloWorld
注意:第三步的時候,如果報錯:
Embedded error: org.apache.maven.archetype.downloader.DownloadNotFoundException:Requested org.apache.maven.archetypes:stripes-archetype-quickstart:jar:1.0download does not exist.Unable to download the artifact from any repository
報錯原因是.m2下缺少maven相關外掛程式archetype。
請到這裡Download下載,然後將下載後的資源解壓,替換掉$HOME/.m2/repository/org/apache/maven這個目錄,然後再次執行,應該ok。
4、maven命令成功執行後,在$HOME(個人目錄)下會看到一個HelloWorld的工程,然後執行如下:
cd HelloWorldmvn jetty:run
5、jetty成功啟動後,去瀏覽器訪問http://localhost:8080/HelloWorld
就會看到:
Congratulations, you've set up a Stripes project!You are running Java version 1.6.0_24 on the Linux operating system.
這樣,我們用maven的stripes外掛程式構建的第一工程就ok了。
6、將該工程編譯成Eclipse工程
mvn clean install
mvn eclipse:clean eclipse:eclipse -Dwtpversion=1.5 -DdownloadSources=true
成功執行後,就可以將該工程import到Eclipse中了。