如何从 Nexus 导入 Maven 依赖项

How to import maven dependencies from Nexus

我正在学习 Nexus 存储库。并尝试将工件上传到 Nexus 上的 Maven 存储库。如何将它导入我的 spring 启动项目?我已通过 Web 界面将 *.jar 文件上传到我的存储库。另外,我已经试过了,但它没有找到我的依赖项。

我遇到了这个错误

> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find mygroup.myartifact:0.0.1:.

这是我试过的

plugins {
    id 'org.springframework.boot' version '2.4.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example.project'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    maven {
        url 'http://nexusUrl:8081/repository/my-repo'

        credentials {
            username = 'admin'
            password = 'admin123'
        }
    }
    mavenCentral()
}

dependencies {
        
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-cache'
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'

    implementation 'mygroup.myartifact:0.0.1'
    
    ...
}

有人能帮帮我吗?

您应该使用 'mygroup:myartifact:0.0.1'(注意 : 而不是 .)。这假设 mygroup 是组,myartifact 是工件名称。