oo

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 name
    • src/
      • 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 path
            • content/ → Resource bundles
            • log4j.properties → Log4J logging configuration
          • webapp/
            • resources/
              • css/ → Style sheets
              • images/ → Images
            • WEB-INF/
              • spring-context/ → Contexts
                • portlet/ → Portlet contexts
                  • portlet1-context.xml → Portlet context
                • portlet-application-context.xml → Application context
              • views/ → View templates
              • liferay-display.xml → Portlet display configuration
              • liferay-plugin-package.properties → Packaging descriptor
              • liferay-portlet.xml → Liferay-specific portlet configuration
              • portlet.xml → Portlet configuration
              • web.xml → Web application configuration
      • test/java/ → Test source files
    • build.gradle → Gradle build file
    • pom.xml → Maven POM