Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEvan Coakley
Courses Plus Student 8,309 PointsGradle build not working
THis is what I have group 'com.teamtreehouse' version '1.0-SNAPSHOT'
buildscript{ repositories{ mavenCentral() } dependencies{ classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE' } }
apply plugin: 'java' apply plugin: 'spring-boot'
sourceCompatibility = 1.8
repositories { mavenCentral() }
dependencies { compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.0.0.M7'
}
IT isn't working. The console says 'the supplied build action failed with an exception' but nothing else. Any ideas?
10 Answers
Michael Switzer
7,490 PointsIt seems Gradle doesn't use "buildscript" anymore. As of March 20, 2019, this gradle build file worked for me:
plugins {
id 'java'
id 'org.springframework.boot' version '2.1.3.RELEASE'
}
group 'giflib'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web:2.1.3.RELEASE'
}
Jose Luis Jiménez Sastre
12,314 PointsThis work for me:
buildscript{
repositories{
mavenCentral()
}
dependencies{
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.12.RELEASE'
}
}
plugins {
id 'java'
id "org.springframework.boot" version "1.5.12.RELEASE"
}
group 'com.teamtreehouse'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.12.RELEASE'
}
It depend of Gradle's version you have.
jeroenoosterwijk
5,456 PointsHad the same problem, after playing around with the version, this is what worked for me:
group 'com.teamtreehouse' version '1.0-SNAPSHOT'
buildscript { repositories{ mavenCentral() } dependencies{ classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE' } }
apply plugin: 'java' apply plugin: 'spring-boot'
sourceCompatibility = 1.8
repositories { mavenCentral() }
dependencies { compile "org.springframework.boot:spring-boot-starter-web:1.5.10.RELEASE"
}
Luis Diaz
6,874 PointsWorked for me!
Dakota Brown
4,041 PointsAs of today, this is the preferred syntax for the Gradle file:
plugins {
id 'java'
id 'org.springframework.boot' version '2.3.4.RELEASE'
}
group 'com.treehouse'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web:2.3.4.RELEASE'
}
Notice the word 'implementation' instead of 'compile.' Since Gradle 3.4, 'compile' has been deprecated. See the documentation here and here for reference.
Gene Higgins
16,582 PointsYou will have to go to the Gradle page to see what the buildscript should look like for your springframework.boot version. E.g., for version 1.5.10
Also you guys should be putting your code into code tags to make it more readable. Reference the Markdown Cheatsheet below.
Xu Zheng
Courses Plus Student 2,879 PointsSame problem
Money Maker
1,196 Pointstry this..
buildscript{ repositories { mavenCentral() } dependencies { classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE' } }
apply plugin: 'java' apply plugin: 'spring-boot'
sourceCompatibility = 1.5
repositories { mavenCentral() }
dependencies { compile("org.springframework.boot:spring-boot-starter-web") }
edisoncardenas2
1,812 PointsTry using: apply plugin: 'org.springframework.boot'
alastair cooper
30,617 Pointsuse the answer from Michael Switzer above and then change your version of gradle by editing the gradle-wrapper.properties file. Sounds complicated but It is very easy and worked great for me
instructions at link below (find the file by right clicking the gradle directory and selecting show in explorer)
Ronald Williams
Java Web Development Techdegree Graduate 25,021 PointsI suggest trying a different version of your dependencies. A lot of times when I get errors with gradle builds, changing the versions to newer ones helps. For example google "org.springframework.boot dependency" to find the other version of that one. Also in the video his source compatibility is 1.5
Jose Mejia
16,758 Pointssame here it gave an error!!
Mehmet Enes Erciyes
1,246 PointsMehmet Enes Erciyes
1,246 PointsYes, and the current version of spring-boot is 2.2.6 now