[Liferay] Liferay 瘦身,Liferay 精简,取消加载 Portlet

本文介绍了如何通过调整Liferay Portal的liferay-portlet.xml文件来选择性加载所需Portlet,从而提升启动速度与界面简洁性。通过在Portlet配置中设置<include>false</include>属性,可以实现对Portal自带Portlet的定制化部署,避免加载不必要的组件,优化系统资源使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

liferay version  :  liferay-portal-6.1.1-ce-ga2

server  : tomcat 7.0.25


Liferay是很庞大,Portal 自带几十个 Portlet, 但是完全可以自己根据需求选择性加载 Portal 自带的 Portlet。


好处就是:

1,启动速度(性能)的提升

2,界面能变得更加简洁,毕竟不需要的 Portlet 都看不到了


看着玄乎其实很简单,就以 Liferay 6.1 版本来说

1. 打开 Portal 的 liferay-portlet.xml

2. 在不需要加载的 Portlet 配置内添加 <include>false</include> 

<portlet>
	<portlet-name>16</portlet-name>
	<icon>/html/icons/currency_converter.png</icon>
	<struts-path>currency_converter</struts-path>
	<preferences-owned-by-group>false</preferences-owned-by-group>
	<use-default-template>false</use-default-template>
	<remoteable>true</remoteable>
	<private-request-attributes>false</private-request-attributes>
	<private-session-attributes>false</private-session-attributes>
	<render-weight>0</render-weight>
	<css-class-wrapper>portlet-currency-converter</css-class-wrapper>
	<include>false</include>
</portlet>


注意 <include>false</include> 在 portlet 里面的得按照规定的顺序,比如上述例子就是在 css-class-wrapper 之后

3. 重启服务看效果吧


有兴趣的可以看看 liferay-portlet.xml 的 dtd 文件 liferay-portlet-app_6_1_0.dtd

里面对 <include> 属性的介绍很详细了。


Set the include value to true to if the portlet is available to the portal. If
set to false, the portlet is not available to the portal. The default value is
true.


Portlets that are not included as part of the portal are never available to the
user to be made active or inactive. As far the user knows, the portlets do not
even exist in the system. This allows the Liferay developers to bundle a lot of
portlets in one core package, and yet allow custom deployments to turn on or off
individual portlets or sets of portlets. This follows the Siebel and Microsoft
model of bundling everything in one core package, but using XML configuration or
registry settings to turn on and off features or sets of features.


We do not recommend that custom deployers modify the core source by removing
specific portlets because this prevents an easy upgrade process in the future.
The best way to turn on and off portlets is to set the include element. The
advantage of this way of doing things is that it becomes very easy to deploy
Liferay. All features are available in one package. The disadvantage is that by
not utilizing all of the portlets, you are wasting disk space and may even take
a small but static memory footprint. However, we feel that the extra disk space
and memory usage is a cheap price to pay in order to provide an easy
installation and upgrade path.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值