爪爪蛙
1 准备开发工具 a) SpringSource Tool Suite 2.9.2.REALEASE:解压即可 http://download.springsource.com/release/STS/2.9.2/dist/e3.7/springsource-tool-suite-2.9.2.RELEASE-e3.7.2-win32-x86_64.zip b) Virgo Tomcat Server 3.5.0.RELEASE:解压即可 http://eclipse.stu.edu.tw//virgo/release/VTS/3.5.0.RELEASE/virgo-tomcat-server-3.5.0.RELEASE.zip c) Virgo插件:通过Update site安装 http://download.eclipse.org/virgo/milestone/tooling2 运行SpringSource Tool Suite a) 进入SpringSource安装目录/sts-2.9.2.RELEASE,点击STS.exe 3 创建Virgo Runtime a) Window->Preferences->Server->Runtime Environment->add b) 输入vi过滤,选中EclicpseRT下的Virgo Runtime,勾选Create a new local server,点击Next c) 点击browse,选中Virgo Tomcat Server安装目录确定 4 管理Bundle依赖 a) 打开Server视图 Window->Show View->Server b) 打开Server编辑器 在Server view中双击已创建好的Virgo Server c) 进入Repository标签页 在Server编辑器下方点击Repository d) 下载hibernate相关bundle 在Repository标签页左上侧输入框输入antlr->点击search,勾选输入框下方搜索结果中的bundles:com.springsource.antlr,点击Repository标签页中间下方的download按钮,依次下载如下bundle com.springsource.antlr-2.7.6.jar com.springsource.com.mysql.jdbc-5.1.6.jar com.springsource.javassist-3.3.0.ga.jar com.springsource.net.sf.cglib-2.1.3.jar com.springsource.org.apache.commons.collections-3.2.1.jar com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar com.springsource.org.apache.commons.pool-1.4.0.jar com.springsource.org.dom4j-1.6.1.jar com.springsource.org.hibernate.annotations.common-3.3.0.ga.jar com.springsource.org.hibernate.annotations-3.4.0.GA.jar com.springsource.org.hibernate-3.3.1.GA.jar com.springsource.org.jgroups-2.5.1.jar e) 查看下载完毕的bundle 下载的bundle存放在Virgo服务器安装目录/Repository/usr目录下,如果不可见,尝试点击右侧Refresh按钮或右下方Update the bundle and library index链接,Virgo服务器安装目录/Repository/ext目录下存放的是服务器自带的bundle 5 开发Bundle 5.1 com.dw.test.datasource a) 创建bundle项目 File->new->project,输入bun过滤,选中Virgo下的bundle项目->next,输入com.dw.test.datasource->next,勾选Enable Bundle Classpath Container,Target runtime下拉框选择Virgo Runtime->finish b) 导入依赖包 双击src/META-INF/MANIFEST.MF->点击下方dependencies标签页->在Import Package区域点击Add按钮->输入com.mysql.jdbc,点击OK。按此步骤依次导入以下依赖包 com.mysql.jdbc,javax.sql,org.apache.commons.dbcp c) 定义Spring bean src/META-INF/spring/appContext.xml
d) 定义Spring OSGi bean src/META-INF/spring/osgiContext.xml
5.2 com.dw.test.domain a) 创建bundle项目,名为com.dw.test.domain,参考5.1 a b) 导入依赖包javax.persistence,javassist.util.proxy,org.hibernate.proxy,参考5.1 b c) 创建并导出共享包 创建包com.dw.test.domain,打开src/META-INF/MANIFEST.MF编辑器->点击runtime标签页->在Exported Packages区域点击Add按钮->输入com.dw.test.domain,点击OK d) 创建entity src/com.dw.test.domain.User.java