spring-cloud-release icon indicating copy to clipboard operation
spring-cloud-release copied to clipboard

The example build.gradle on https://projects.spring.io/spring-cloud/ doesn't work

Open xak2000 opened this issue 8 years ago • 0 comments

I don't know if this repo is good place for this issue but can't find a better place. Feel free to point me to right repo if this is wrong one.

The build.gradle example from https://projects.spring.io/spring-cloud/ doesn't work at all.

If I select Finchley.M4 version, copy provided build.gradle into clipboard, paste it, then do gradle build, the build fails with:

Could not find org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M6.

If I select Edgware (GA) version, copy provided build.gradle into clipboard, paste it, then do gradle build, the build fails with:

> gradle build

> Configure project :
The plugin id 'spring-boot' is deprecated. Please use 'org.springframework.boot' instead.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRepackage'.
> Could not resolve all dependencies for configuration ':runtime'.
   > Cannot resolve external dependency :spring-cloud-starter-config: because no repositories are defined.
     Required by:
         project :
   > Cannot resolve external dependency :spring-cloud-starter-eureka: because no repositories are defined.
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
3 actionable tasks: 3 executed

Also please note that spring-boot plugin is deprecated, the new plugin name is org.springframework.boot.

For Edgware (based on spring-boot 1.5.9) the fix is:

  1. Add
repositories {
	mavenCentral()
}
  1. Add dependency group org.springframework.cloud to both
dependencyManagement {
  imports {
    mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE'
  }
}

and

dependencies {
    compile 'org.springframework.cloud:spring-cloud-starter-config'
    compile 'org.springframework.cloud:spring-cloud-starter-eureka'
}

Without this gradle cannot resolve dependencies.

Maybe the trick with skipping dependency group only works since spring-boot 2.0?

Current not working build.gradle for Edgware from https://projects.spring.io/spring-cloud/

buildscript {
	ext {
		springBootVersion = '1.5.9.RELEASE'
	}
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
	}
}

apply plugin: 'java'
apply plugin: 'spring-boot' 

dependencyManagement {
  imports {
    mavenBom ':spring-cloud-dependencies:Edgware.RELEASE'
  }
}

dependencies {
    compile ':spring-cloud-starter-config'
    compile ':spring-cloud-starter-eureka'
}

xak2000 avatar Dec 19 '17 17:12 xak2000