Using Service Builder in a Maven Project

The easiest way to add Service Builder to your Maven project is to create a new Maven project using Liferay’s provided Service Builder archetype; it’s configured in the new project by default. You can learn how to generate a Service Builder Maven project by visiting the Service Builder Template article.

In some cases, you should not use this template due to a number of reasons:

  • You’re updating a legacy Maven project to follow OSGi modular architecture.
  • You have a pre-existing modular Maven project and don’t want to start over.

For these cases, you can configure Service Builder in your project manually. Follow the instructions below to configure Service Builder in your Maven project!

  1. Apply the Service Builder plugin in your Maven project’s pom.xml file:


    The configuration tag used above is an example of what a Service Builder project’s configuration could look like. All the configuration attributes above should be modified to fit your project.

    The above code configures Service Builder for a sample basic-service module. When running Service Builder with this configuration, the project’s API classes are generated in the basic-api module’s src/main/java folder. You can also specify your hibernate module mappings, implementation directory name, model hints file, Spring configurations, SQL configurations, etc. You can reference all the configurable Service Builder properties in the Service Builder Plugin reference article.

  2. Apply the WSDD Builder plugin declaration directly after the Service Builder plugin declaration:


    The WSDD Builder is required to generate your project’s remote services.

    See the WSDD Builder Plugin article for more information on the configuration properties.

Terrific! You’ve successfully configured your Maven project to use Service Builder by applying the Service Builder and WSDD Builder plugins in your project’s POM.

« Compiling Sass Files in a Maven ProjectUpgrading Your Maven Build Environment »
0 人中有 0 人觉得有帮助