Developers creating portlets for Liferay DXP can usually deploy their portlet as
Java EE-style Web Application ARchive (WAR) artifacts or as Java ARchive (JAR)
OSGi bundle artifacts. Spring MVC portlet developers don’t have that
flexibility. Spring MVC portlets must be packaged as WAR artifacts because the
Spring MVC framework is designed for Java EE. Therefore, it expects a WAR layout
and requires Java EE resources such as the WEB-INF/web.xml descriptor.
Because Liferay supports the OSGi WAB (Web Application Bundler) standard for
deployment, you can deploy your WAR and it runs as expected in the OSGi
runtime. Here are the high points on why that works in Liferay:
The Liferay auto-deploy process runs, adding the PortletServlet and
PlugincontextListener configurations to the WEB-INF/web.xml file.
Liferay WAB Generator
automatically creates an OSGi-ready META-INF/MANIFEST.MF file. If you want
to affect the content of the manifest file, you can place bnd directives and
OSGi headers directly into a WEB-INF/liferay-plugin-package.properties
file for the WAB.
Import class packages
your portlet’s descriptor files reference by adding the packages to an
Import-Package header in your liferay-plugin-package.properties file.
The auto-deploy process and Liferay’s WAB generator convert your project to a
Liferay-ready WAB. The WAB generator detects your class’s import statements
and adds all external packages to the WAB’s Import-Package header. The
generator merges packages from your plugin’s liferay-plugin-package.properties
into the header also.