最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jar - how to upload spring boot artifact in nexus repository then use them in other spring boot project - Stack Overflow

programmeradmin2浏览0评论

I uploading a spring boot project jar in nexus repository, and when use it as dependency in an other project locally, it doesn't recognize the import statement even though it fetch the dependency from the hosted repository in nexus
here is the build.gradle for the project that i want to package and upload it in nexus repository

plugins {
  id 'java'
  id 'maven-publish'
  id 'java-library'
  id '.springframework.boot' version '3.4.3'
  id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.example'
version = '0.0.1'
java {
  toolchain {
      languageVersion = JavaLanguageVersion.of(17)
  }
  withJavadocJar()
  withSourcesJar()
}
configurations {
  compileOnly {
      extendsFrom annotationProcessor
  }
}
repositories {
  mavenCentral()
}
publishing {
  publications {
      mavenJava(MavenPublication) {
          from components.java
          versionMapping {
              usage('java-api') {
                  fromResolutionResult()
              }
              usage('java-runtime') {
                  fromResolutionResult()
              }
          }
      }
  }
  repositories {
      maven {
          url "repository/url"
          credentials {
              username = "username"
              password = "password"
          }
          allowInsecureProtocol = true
      }
  }
}
dependencies {
  implementation '.springframework.boot:spring-boot-starter-data-jpa'
  implementation '.springframework.boot:spring-boot-starter-web'
  compileOnly '.projectlombok:lombok'
  runtimeOnly '.postgresql:postgresql'
  annotationProcessor '.projectlombok:lombok'
  testImplementation '.springframework.boot:spring-boot-starter-test'
  testRuntimeOnly '.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
  useJUnitPlatform()
}




then in other spring boot project this is an example of the build.gradle file

plugins {
  id 'java'
  id '.springframework.boot' version '3.4.3'
  id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
java {
  toolchain {
      languageVersion = JavaLanguageVersion.of(17)
  }
}
repositories {
  mavenCentral()
  maven {
      url "repository/url/in/nexus"
      credentials{
          username = "username"
          password = "password"
      }
  }
}
dependencies {
  implementation '.springframework.boot:spring-boot-starter'
  
  ***implementation 'com.example:myproject:version'***
  
  testImplementation '.springframework.boot:spring-boot-starter-test'
  testRuntimeOnly '.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
  useJUnitPlatform()
}

when refrshing dependencies it fetch the dependecy from the repository, but the import statement don't recognize the artifact

发布评论

评论列表(0)

  1. 暂无评论