Could not find artifact com.alibaba.cloud:spring-cloud-starter-stream-rocketmq:pom:unknown in alimav

 My mq initial project is like this

 

1: Problem description

According to the RocketMQ official website, perform the operation, and then need to introduce rocketmq according to the dependencies of the official website.

The following problem will occur

Could not find artifact com.alibaba.cloud:spring-cloud-starter-stream-rocketmg:pom:4.9.3 in aliyunmaven
(https://maven.aliyun.com/repository/public)

The pom.xml file under mq2.3_rmqdemo
<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>

    <groupId>com.shimmer</groupId>
    <artifactId>MQ</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>mq2.3_rmqdemo</module>
    </modules>

    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>2.3.12.RELEASE</version>
    </parent>

    <name>MQ</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <com.cloud.version>Hoxton.SR12</com.cloud.version>
        <com.alibaba.cloud.version>2.2.8.RELEASE</com.alibaba.cloud.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${com.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${com.alibaba.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

 

Solution 1:

How do I delete the local maven package and then reload the project or clear maven? Installing again still doesn't work, and I still get this error, showing that Alibaba Cloud does not have this version.

Solution 2: 

Then I went to the maven warehouse to find the relevant version to import. It could be downloaded, but there was a problem with the project.

Then I went to look at Warehouse Services Warehouse Services and found this sentence above

 Then I changed the image and replaced the image with a new one.

<mirror>
  <id>aliyunmaven</id>
  <mirrorOf>*</mirrorOf>
  <name>阿里云公共仓库</name>
  <url>https://maven.aliyun.com/repository/public</url>
</mirror>

 Still not working after that

Solution three:

Because the reference on the official website does not have a relevant version and no displayed reference, it refers to the version of the parent class, so the parent class must allow subclasses to reuse it.

The pom.xml file under mq, my original parent pom file is like this

<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>

    <groupId>com.shimmer</groupId>
    <artifactId>MQ</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>mq2.3_rmqdemo</module>
    </modules>

    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>2.3.12.RELEASE</version>
    </parent>

    <name>MQ</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <com.cloud.version>Hoxton.SR12</com.cloud.version>
        <com.alibaba.cloud.version>2.2.8.RELEASE</com.alibaba.cloud.version>
    </properties>

        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${com.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${com.alibaba.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
</project>

 The parent class pom file can download the package normally without any problem, but there is a problem with the subclass.

There is a sentence in Alibaba Java Developer Specifications

 

Suddenly I thought about it and realized that public use needs to be placed in <dependencyManagement>. I didn't add direct dependencies in the parent version to start.

So change the parent class to

<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>

    <groupId>com.shimmer</groupId>
    <artifactId>MQ</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>mq2.3_rmqdemo</module>
    </modules>

    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>2.3.12.RELEASE</version>
    </parent>

    <name>MQ</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <com.cloud.version>Hoxton.SR12</com.cloud.version>
        <com.alibaba.cloud.version>2.2.8.RELEASE</com.alibaba.cloud.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${com.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${com.alibaba.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

 

Be sure to add dependencyManagement, don’t paste it carelessly.

 

Moving forward is the courage to not be afraid of difficulties

Guess you like

Origin blog.csdn.net/qq_45656077/article/details/132430869