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>
上一篇 Spring Cloud服务网关Zuul高级篇
下一篇 Spring Cloud Feign报错'xx.FeignClientSpecification', defined in null, could not be registered
目录
文章列表
1 MySQL视图详解
MySQL视图详解
2
Flutter Widget之Icon
Flutter Widget之Icon
3
Flutter Widget之BottomNavigationBar
Flutter Widget之BottomNavigationBar
4
云服务器挂载数据盘
云服务器挂载数据盘
5
Prometheus + Grafana 使用 redis_exporter 监控 Redis
Prometheus + Grafana 使用 redis_exporter 监控 Redis
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。