Virgo运行Greenpages案例
1 安装Virgo tomcat server
下载
解压缩到D:\virgo-tomcat-server-3.5.0.RELEASE下,运行其下bin\startup.bat可以启动服务器。
2 安装Apache Marven
http://maven.apache.org
3 Greenpages简介
GreenPages is a simple application that allows users to search an online email address directory. Each listing in the directory details the relevant email addresses and the name of the owner. GreenPages has only three screens: the search screen, the results screen and the listing detail screen.
In the search screen, users can enter search criteria to be matched against the listings in the directory. The result screen displays any listings that match the criteria entered by the user. The listing detail screen shows all the data known about a given listing.
Despite its simplicity, GreenPages is designed to demonstrate many different Virgo Tomcat Server features and to act as a template from which other modular applications can be built. In particular, GreenPages demonstrates:
bundle dependencies with
Spring Framework 3.0;
FreeMarker 2.3;
EclipseLink 1.0.0;
H2 1.0.71; and
Commons DBCP 1.2.2.
The GreenPages application is packaged as a PAR file containing four bundles.
The
greenpages.db
bundle provides access to an external database and publishes ajavax.sql.DataSource
service.The
greenpages.app
bundle exports agreenpages
package containingDirectory
andListing
interfaces.The
greenpages.jpa
bundle imports thegreenpages
package and uses thejavax.sql.DataSource
service to access the external database and publishes its contents as agreenpages.Directory
service.The
greenpages.web
web application bundle imports thegreenpages
package and uses thegreenpages.Directory
service to respond to web requests.(来源:http://www.eclipse.org/virgo/documentation/greenpages-documentation-2.5.0.RELEASE/docs/htmlsingle/greenpages-guide.html)
4 安装Greenpages
下载Greenpages最新版,2.5版;解压缩后文件夹结构如:
d:\greenpages-2.5.0.RELEASE\db,....
5 编译
进入DOS命令符
d:\greenpages-2.5.0.RELEASE>mvn package
大约花费6分多钟,出现所有项目Success后,
在d:\greenpages-2.5.0.RELEASE\greenpages会出现target文件夹。
6 数据库参数设置
d:\greenpages-2.5.0.RELEASE> cd db
d:\greenpages-2.5.0.RELEASE\db> run
浏览器出现参数设置窗口,用默认值,关闭该窗口
d:\greenpages-2.5.0.RELEASE\db> data
7 部署
拷贝d:\greenpages-2.5.0.RELEASE\greenpages\target\greenpages-2.5.0.RELEASE.par文件到D:\virgo-tomcat-server-3.5.0.RELEASE\pickup下。
8 测试
Dos下进入D:\virgo-tomcat-server-3.5.0.RELEASE\bin下,运行命令startup -clean
在浏览器中,访问http://localhost:8080/greenpages/app/home.htm
输入参数on,查询看结果。
运行正常
疑问:数据库参数设置后,其连接参数及创建的数据难道写入.par文件中了?否则,为什么拷贝.par文件后数据已存在于数据库中了?