我必须将spring boot项目发布到工件,并且需要在清单中添加一些信息。我的build.gradle文件如下所示:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
bootJar {
baseName = 'my-project'
def gitBranch = java.util.Optional.ofNullable(System.getenv('git.branch')).orElse('no information')
def gitCommit = java.util.Optional.ofNullable(System.getenv('git.commit')).orElse('no information')
def gitBuildNumber = java.util.Optional.ofNullable(System.getenv('git.buildno')).orElse('no information')
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
)
}
}
我在class-path
行出现如下错误,
A problem occurred evaluating root project 'my-project'.
> Could not resolve all dependencies for configuration ':detachedConfiguration1'.
> Cannot resolve external dependency org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE because no repositories are defined.
Required by:
project :
如何解决此问题?
答案 0 :(得分:0)
从dependencies
中取出buildScript
,如下所示。
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
dependencies {
...........
}
答案 1 :(得分:0)
两个块repositories
和dependencies
可以定义为顶级块,也可以定义为buildscript
块之下。顶级块用于定义代码的生产依赖性以及如何解决它们。 buildscript
块中的块用于定义插件依赖性以及如何解决它们:
buildscript {
repositories {
// define how to resolve plugin dependencies
jcenter()
}
dependencies {
// define plugin dependencies
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE"
}
}
repositories {
// define how to resolve production dependencies
jcenter()
}
dependencies {
// define production dependencies
compile "org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE"
}