简体   繁体   English

如何从 Nexus 导入 maven 依赖项

[英]How to import maven dependencies from Nexus

I'm learning about Nexus Repository.我正在学习 Nexus 存储库。 And tried uploading an artifact to the maven repository on Nexus.并尝试将工件上传到 Nexus 上的 maven 存储库。 How can I import it into my spring boot project?如何将它导入到我的 spring 引导项目中? I have uploaded *.jar file via web interface to my repository.我已经通过 web 接口将 *.jar 文件上传到我的存储库。 Also, I have tried it but it doesn't find my dependencies.另外,我已经尝试过了,但它没有找到我的依赖项。

I got this error我收到了这个错误

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

Here's what I tried这是我尝试过的

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'
    
    ...
}

Can anyone help me, please?任何人都可以帮助我吗?

You should use 'mygroup:myartifact:0.0.1' (note the: instead of the.).您应该使用'mygroup:myartifact:0.0.1' (注意:而不是。)。 This assumes that mygroup is the group and myartifact is the artifact name.这假定mygroup是组, myartifact是工件名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM