liferay portal尝试

这几天研究了一下liferay,其中也遇到过一些问题,不过现在已经基本跑通了

我下载的是liferay5.2.2,liferay好像每个版本之间的变化都挺大的。这个版本集成的是tomcat6.0。

 

主要参考了两个文章:

http://neujingxiao.blog.163.com/blog/static/51394720088111141313/

http://sujili1234.javaeye.com/blog/347870

 

一、直接下载liferay-portal-tomcat-6.0-5.2.2.zip,然后解压缩,进入tomcat的bin目录,执行startup.bat运行成功,系统会自己开启一个IE窗口,进入你的portal的页面。初始页面是guest用户的页面,http://localhost:8080/web/guest。如果你要进入个人的页面,可以通过右侧的一个下拉框,选择sign in登录,这个版本的用户名和密码是:用户名:bruno@7cogs.com,密码:bruno

 

二、建立自己的开发环境:

1)、准备工作:

下载安装ant

下载安装Jikes

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> 配置系统环境参数

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> 下载安装Eclipse

下载liferay-portal-src-5.2.2.zip,解压缩

2)、配置环境:

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

1)建立扩展开发目录ext

先确认自己电脑的Windows用户名。在C:/Projects/liferay-5.1.0/portal/目录中建立属性文件release.{用户名}.properties,本人的用户名是jingxiao,因此要建立的文件名是release.jingxiao.properties,文件内容只有一行:

lp.ext.dir=C:/projects/liferay-5.1.0/ext

然后进入DOS窗口,转入目录C:/Projects/liferay-5.1.0/portal/,执行命令:

ant clean start build-ext

若干分钟后命令执行完成,在C:/Projects/liferay-5.1.0/目录中建立了ext子目录,这是进行二次开发的扩展目录,包含了从源程序目录portal中建立并复制来的java类包、源程序、属性文件和配置文件等等。

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

2)部署扩展开发环境

接下来要测试新建的扩展开发环境是否可用,能否正确生成运行环境。

打开扩展开发目录ext中的部署属性文件app.server.properties,找到 单独使用Tomcat服务器的定义参数部分。在该属性文件中,缺省定义Tomcat服务器使用的是Tomcat 5.5版本,而我们使用的是Tomcat 6.0服务器(Liferay-5.1.0+Tomcat-6.0集成包),因此要把原来Tomcat 6.0属性定义的注释符号去除掉(有关Tomcat 5.5的定义还要保留),使得下列定义语句有效:

app.server.tomcat.version=6.0

app.server.tomcat.dir=${app.server.parent.dir}/tomcat-6.0.16

app.server.tomcat.classes.global.dir=${app.server.tomcat.dir}/lib

app.server.tomcat.lib.endorsed.dir=${app.server.tomcat.dir}/lib/ext

app.server.tomcat.lib.global.dir=${app.server.tomcat.dir}/lib/ext

app.server.tomcat.lib.support.dir=${app.server.tomcat.dir}/lib/ext

app.server.tomcat.support.dir=${app.server.tomcat.dir}/lib/ext

app.server.tomcat.zip.name=liferay-portal-tomcat-6.0-${downloads.version}.zip

然后在扩展开发目录ext下,建立对应于用户名的扩展部署属性文件app.server.{用户名}.properties,即app.server.jingxiao.properties,其内容如下:

app.server.type=tomcat

app.server.tomcat.dir=C:/Projects/liferay-5.1.0/tomcat-6.0

最后,在DOS窗口中进入扩展开发目录C:/Projects/liferay-5.1.0/ext/,执行命令:

ant clean deploy

经过几分钟的处理后,当DOS窗口出现BUILD SUCCESSFULE提示时,部署成功,ext目录中的内容经过编译打包后部署到了运行环境tomcat-6.0目录下。

现在来测试重新部署的Liferay Portal是否工作正常。进入tomcat-6.0/bin/目录,执行startup.bat启动LiferayMySQL数据库和LDAP服务器应该优先启动),用浏览器打开网址http://localhost:8080/,展现出同部署前一样的界面。以admin用户登录一切正常。

但由于使用了ant clean,将把已经部署到Tomcat的其他应用(webapps目录中)给删除了。因此,要么只用ant deploy来部署,要么事先备份好非Liferay Portal的那些应用目录,如Liferay的主题风格插件。

3)建立eclipse开发项目

启动eclipse,指定工作项目目录为C:/Project/liferay-5.1.0/。在eclipse启动后的主窗口中,把鼠标移到右边的Workbench图标上,打开eclipse的工作台面。

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

先建立一个Java项目ext。在主菜单File列表中,依次点击New->Other…。 在打开的New过滤窗口中,点开Java项目,选择Java Project子项目并按Next按钮进入下一步配置。在New Java Project窗口中,指定Project Nameext;在Content栏目中,选择“Create project from existing source”,并在Directory栏目浏览选择现有项目的目录为C:/Projects/liferay-5.1.0/ext/。其他选项不予理 会,直接按Finish按钮,eclipse将会在左侧的Package Ext窗口下建立ext项目。

3、 <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

Liferay应用开发

在我们建立的eclipse开发环境中进行应用开发。按照Liferay的建议,二次开发最 好是在ext项目中进行。而且在ext项目中,Liferay的核心内容是经过打包后复制过来的,对Liferay的修改或应用开发要按照Liferay 的建议,以扩展的形式来实现。这样的话,当Liferay升级更新了源码后,重新生成ext项目时也不会覆盖原来在ext中所作的变动。

 

。。。。。。。。。。。。

不多说这些了,网上有很多这方面的资料。

 

4、配置MYSQL

在用eclipse开发完EXT和PORTLET后,部署到TOMCAT上,然后打开$TOMCAT_HOME/webapps/ROOT/WEB-INF目录
创建 portal-ext.properties 文件

在文件内输入

jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=root

打开 $TOMCAT_HOME/common/lib/ext 目录
放入对应的 数据库JAR包 特殊数据库 需要到官方下载 数据结构和数据
(数据库自带HSQL 支持MYSQL 自动初始化 数据结构及数据)
打开 F:/liferay-portal-5.2.2/tomcat-5.5.27/conf/Catalina/localhost目录
在目录下 修改ROOM.XML
如下
<Resource
             name="jdbc/LiferayPool"
             auth="Container"
             type="javax.sql.DataSource"
             driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false"
             username="root"
             password="root"
             maxActive="20"
      />

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值