pom.xml configuration

更新时间:
复制 MD 格式

This article describes the configuration file pom.xml in the SOFABoot Web and Core projects. The difference in configuration between the two projects is mainly the difference in <module> content.

Configuration guide for pom.xml in web projects

For the complete pom.xml configuration of a SOFABoot Web project, see pom.xml. The following section will provide a detailed introduction to key tags in the pom.xml file for SOFABoot Web projects.

Parent tag

Please navigate to the version description to check the latest SOFABoot version, then modify the version number in the example item shown below within the main pom.xml file in your project's root directory:

版本号

Project tag

Within the <project> tag, the declared project coordinates include the following elements. You may modify them according to your project requirements:

  • modelVersion: Declares the POM model version that the project description should follow.

  • groupId: The globally unique identifier of the project, typically the reverse of a company or organization domain name (e.g., com.alipay.sofa in the sample project).

  • artifactId: The artifact identifier of the project.

  • version: The project version number. SNAPSHOT indicates a development snapshot (unstable version).

  • packaging: The type of artifact generated by the project (e.g., jarwarearpom).

  • name: The project name (optional).

  • url: The project homepage URL (optional).

For detailed explanations of these elements, refer to the Apache Maven documentation.

Dependencies tag

In the <dependencies> tag, all dependencies related to the project are declared as follows:

Module tag

By default, the project prototype generates the app/endpoint and app/web modules:

<modules>
     <module>app/endpoint</module>
     <module>app/web</module>
</modules>

endpoint module

The endpoint module is the service module of SOFAREST and provides SOFAREST services. By default, the SOFAREST dependency is added to the app/endpoint module of the SOFABoot web project.

<dependency>
  <groupId>com.alipay.sofa</groupId>
  <artifactId>rest-enterprise-sofa-boot-starter</artifactId>
</dependency>

SOFABoot uses a series of {XXXXXX}-sofa-boot-starter to manage middleware dependencies. For example, if you want to add a dependency on RPC middleware, you can add the following configuration to the pom.xml:

<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>rpc-enterprise-sofa-boot-starter</artifactId>
</dependency>

web module

The web module is a startup module that contains main functions and can be run directly. At the same time, the global configuration files and static resources are placed under this module.

Package deployment instructions

The SOFABoot Web project configures the build (build) in the Web module, uses spring-boot-maven-plugin as the build tool, and generates a fat JAR(.jar) package under the target of the project root directory. The fat JAR package is a deployable unit. It can be deployed on-premises or in the cloud.

  • Local deployment: You can run the java -jar command to start the .jar package;

  • Cloud deployment: When you upload the file to the SOFAStack platform for deployment, you only need to upload the fat JAR file. The SOFABoot technology stack will automatically work with the SOFAStack deployment platform to deploy the file for you.

An example of a build tag is as follows:

<build>
    <plugins>
        <!-- http://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html -->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <!-- http://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html -->
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.4.2.RELEASE</version>
            <configuration>
                <! -- The deployable fat JAR is packaged under the target of the project root directory -->
                <outputDirectory>../../target</outputDirectory>
                <classifier>executable</classifier>
            </configuration>
            <executions>
                <execution>
                    <goals>
                    <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Configuration guide for pom.xml in Core project

For the complete pom.xml configuration of a SOFABoot Core project, see pom.xml. The following section will provide a detailed introduction to key tags in the pom.xml file for SOFABoot Core projects.

Parent tag

Please navigate to the version description to check the latest SOFABoot version, then modify the version number in the example item shown below within the main pom.xml file in your project's root directory:

版本号

Project tag

For more information, see the Web project description.

Dependencies tag

In the <dependencies> tag, all dependencies related to the project are declared as follows:

Module tag

By default, the project prototype generates the APPNAME-facade and APPNAME-service modules:

<modules>
     <module>APPNAME-facade</module>
     <module>APPNAME-service</module>
</modules>

facade module

The facade module is used to define the interface of the service, and it is easy to distribute the JAR packaged by this module to the caller of the service when using RPC middleware.

service module

The configuration information of the service module includes global configuration, application log configuration file, and technology stack configuration information. The service module introduces all the dependencies required by the facade module and the RPC middleware. Here is the pom.xml of service module:

  • Download pom.xml for service module

  • Description of the pom.xml file of the service module

    !" -- The facade dependency -->
    <dependency>
         <groupId>com.alipay.sofa</groupId>
         <artifactId>APPNAME-facade</artifactId>
    </dependency>
    <! -- Introduced all dependencies required by the RPC middleware -->
    <dependency>
         <groupId>com.alipay.sofa</groupId>
         <artifactId>rpc-enterprise-sofa-boot-starter</artifactId>
    </dependency>

Package deployment instructions

For more information about packaging and deployment, see Packaging and deployment in the Web project.