Migrating to PortletMVC4Spring

To continue developing a portlet to use Spring Framework version 5.0 onward, migrate it from Spring Portlet MVC to PortletMVC4Spring. Here are the steps:

  1. In your pom.xml or build.gradle descriptor, use the Spring Framework version 5.1.x artifacts by replacing dependencies on the spring-webmvc-portlet artifact with the com.liferay.portletmvc4spring.framework artifact.

    Maven:

    <dependency>
        <groupId>com.liferay.portletmvc4spring</groupId>
        <artifactId>com.liferay.portletmvc4spring.framework</artifactId>
        <version>5.1.0</version>	
    </dependency>
    <dependency>
        <groupId>com.liferay.portletmvc4spring</groupId>
        <artifactId>com.liferay.portletmvc4spring.security</artifactId>
        <version>5.1.0</version>	
    </dependency>
    

    Gradle:

    compile group: 'com.liferay.portletmvc4spring', name: 'com.liferay.portletmvc4spring.framework', version: '5.1.0'
    compile group: 'com.liferay.portletmvc4spring', name: 'com.liferay.portletmvc4spring.security', version: '5.1.0'
    
  2. In your WEB-INF/portlet.xml descriptor, replace uses of org.springframework.web.portlet.DispatcherPortlet with com.liferay.portletmvc4spring.DispatcherPortlet.

  3. Replace uses of the Spring Portlet MVC AnnotationMethodHandlerAdapter class with the PortletMVC4Spring PortletRequestMappingHandlerAdapter class. PortletRequestMappingHandlerAdapter uses the HandlerMethod infrastructure that Spring Web MVC 5.1.x is based on.

  4. If you specified AnnotationMethodHandlerAdapter as a <bean> in a Spring configuration descriptor, replace its fully-qualified class name org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter with com.liferay.portletmvc4spring.mvc.method.annotation.PortletRequestMappingHandlerAdapter.

    Also address these bean property changes:

  5. If you’re using Apache Commons Fileupload, update your Spring configuration descriptor:

    1. Replace this legacy bean:

      <bean id="portletMultipartResolver"
      	class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver" />
      

      With this new one from PortletMVC4Spring:

      <bean id="portletMultipartResolver"
      	class="com.liferay.portletmvc4spring.multipart.CommonsPortletMultipartResolver" />
      
    2. Remove these dependencies from your pom.xml or build.gradle descriptor:

      <dependency>
      	<groupId>commons-fileupload</groupId>
      	<artifactId>commons-fileupload</artifactId>
      </dependency>
      <dependency>
      	<groupId>commons-io</groupId>
      	<artifactId>commons-io</artifactId>
      </dependency>
      
  6. Throughout your project, replace all uses of the org.springframework.web.portlet package path with com.liferay.portletmvc4spring.

  7. Continue developing your portlet using PortletMVC4Spring.

  8. Build and deploy your project.

Congratulations! You migrated your project from Spring Portlet MVC to PortletMVC4Spring.

PortletMVC4Spring

Developing a Portlet Using PortletMVC4Spring

Configuring Dependencies

« Developing a Portlet Using PortletMVC4SpringJSF Portlet »
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0