PortletMVC4Spring Project Anatomy
PortletMVC4Spring portlets are packaged in WARs. Liferay provides Maven archetypes for creating projects configured to use JSP/JSPX and Thymeleaf templates. Their commands are listed below. The PortletMVC4Spring project structure follows the commands.
Maven Commands for Generating PortletMVC4Spring Projects
Here are Maven commands for generating PortletMVC4Spring portlet projects that use JSPX and Thymeleaf View templates:
SP/JSPX Form Portlet
mvn archetype:generate \
* DarchetypeGroupId=com.liferay.portletmvc4spring.archetype \
* DarchetypeArtifactId=com.liferay.portletmvc4spring.archetype.form.jsp.portlet \
* DarchetypeVersion=5.1.0 \
* DgroupId=com.mycompany \
* DartifactId=com.mycompany.my.form.jsp.portlet
Thymeleaf Form Portlet
mvn archetype:generate \
* DarchetypeGroupId=com.liferay.portletmvc4spring.archetype \
* DarchetypeArtifactId=com.liferay.portletmvc4spring.archetype.form.thymeleaf.portlet \
* DarchetypeVersion=5.1.0 \
* DgroupId=com.mycompany \
* DartifactId=com.mycompany.my.form.thymeleaf.portlet
Project Structure
The Maven commands generate a project that includes Model and Controller classes, View templates, a resource bundle, a stylesheet, and more. The Spring contexts and configuration files set PortletMVC4Spring development essentials. Here’s the resulting project structure:
[com.mycompany.my.form.jsp.portlet]
/ → Arbitrary project namesrc/
main/
java/[my-package-path]/
controller/
→ Sub-package for Controller classes (optional)dto/
→ Sub-package for Model (data transfer object) classes (optional)resources/
→ Resources to include in the class pathcontent/
→ Resource bundleslog4j.properties
→ Log4J logging configuration
webapp/
resources/
css/
→ Style sheetsimages/
→ Images
WEB-INF/
spring-context/
→ Contextsportlet/
→ Portlet contextsportlet1-context.xml
→ Portlet context
portlet-application-context.xml
→ Application context
views/
→ View templatesliferay-display.xml
→ Portlet display configurationliferay-plugin-package.properties
→ Packaging descriptorliferay-portlet.xml
→ Liferay-specific portlet configurationportlet.xml
→ Portlet configurationweb.xml
→ Web application configuration
test/java/
→ Test source files
build.gradle
→ Gradle build filepom.xml
→ Maven POM