Spring Cloud开发pom.xml踩坑记录

API接口部署配置

如需要发布至中央仓库(比如API工程),则取消以下默认plugin依赖

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

否则报如下错误

api deploy repackage failed: Unable to find main class

服务实现配置

实现逻辑的工程中,建议加上以下plugin依赖,避免deploy到Maven

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

父Module与子Module配置

注意:叶子Module使用<packaging>jar</packaging>,父Module使用<packaging>pom</packaging>

父Module pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>appblog-pay-provider</artifactId>
        <groupId>cn.appblog.pay</groupId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>appblog-pay-provider-channel</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>appblog-pay-provider-channel</name>
    <packaging>pom</packaging>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <modules>
        <module>appblog-pay-provider-channel-common</module>
        <module>appblog-pay-provider-channel-gateway</module>
        <module>appblog-pay-provider-channel-core</module>
        <module>appblog-pay-provider-channel-callback</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>

子Module pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>cn.appblog.pay</groupId>
        <artifactId>appblog-pay-provider-channel</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>appblog-pay-provider-channel-core</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>appblog-pay-provider-channel-core</name>
    <packaging>jar</packaging>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <version>2.1.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign-core</artifactId>
            <version>2.1.1.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-commons</artifactId>
            <version>2.1.1.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.lianlian.global.pay</groupId>
            <artifactId>appblog-pay-provider-channel-core-api</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/11/spring-cloud-development-pom-xml-footstep-record/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Spring Cloud开发pom.xml踩坑记录
API接口部署配置 如需要发布至中央仓库(比如API工程),则取消以下默认plugin依赖 <build> <plugins> <plugin> ……
<<上一篇
下一篇>>
文章目录
关闭
目 录