Service Wrapper Template

In this article, you’ll learn how to create a Liferay service wrapper as a Liferay module. To create a Liferay service wrapper via the command line using Blade CLI or Maven, use one of the commands with the following parameters:

blade create -t service-wrapper -v 7.0 [-p packageName] [-c className] [-s serviceWrapperClass] projectName


mvn archetype:generate \
    -DarchetypeGroupId=com.liferay \
    -DarchetypeArtifactId=com.liferay.project.templates.service.wrapper \
    -DartifactId=[projectName] \
    -Dpackage=[packageName] \
    -DclassName=[className] \
    -DserviceWrapperClass=[serviceWrapperClass] \

You can also insert the -b maven parameter in the Blade command to generate a Maven project using Blade CLI.

The template for this kind of project is service-wrapper. Suppose you want to create a service wrapper project called service-override with a package name of and a class name of UserLocalServiceOverride. Also, you’d like to create a service of type com.liferay.portal.kernel.service.ServiceWrapper that extends the com.liferay.portal.service.UserLocalServiceWrapper class. You could run the following command to accomplish this:

blade create -t service-wrapper -v 7.0 -p -c UserLocalServiceOverride -s com.liferay.portal.kernel.service.UserLocalServiceWrapper service-override


mvn archetype:generate \
    -DarchetypeGroupId=com.liferay \
    -DarchetypeArtifactId=com.liferay.project.templates.service.wrapper \
    -DgroupId=com.liferay \
    -DartifactId=service-override \ \
    -Dversion=1.0 \
    -DclassName=UserLocalServiceOverride \
    -DserviceWrapperClass=com.liferay.portal.kernel.service.UserLocalServiceWrapper \
    -Dauthor=Joe Bloggs \

Here, service means an OSGi service, not a Liferay API. Another way to say service type is to say component type.

After running the command above, your project’s directory structure looks like this:

  • service-override
    • gradle (only in Blade CLI generated projects)
      • wrapper
        • gradle-wrapper.jar
    • src
      • main
        • java
          • com/liferay/docs/serviceoverride
    • bnd.bnd
    • build.gradle
    • [gradlew|pom.xml]

The generated module is a working application and is deployable to a Liferay DXP instance. To build upon the generated app, modify the project by adding logic and additional files to the folders outlined above.

« Service Builder TemplateSimulation Panel Entry Template »
Was this article helpful?
0 out of 0 found this helpful