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 trial

Java Spring Basics Introduction and Setting up Our Development Tools Gradle in Action

build script no longer used in spring boot starter web gradle file, what is current format?

I saw a format without the build script in the Treehouse tutorial but cannot find it now??

1 Answer

Ryan S
Ryan S
27,276 Points

Hi David,

Are you referring to the Spring Configuration video? This is the video where the spring-boot-starter-web library is added, however, as the video shows, there is no build script required to import this library.

If you mean the spring boot gradle plugin, which allows us to deploy the app to a web server, then in later versions of gradle you do not need a build script in order to apply it:

plugins {
    id "org.springframework.boot" version "2.0.1.RELEASE"
}

group 'com.teamtreehouse'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web:2.0.1.RELEASE'
}

Alternatively, you can still use the buildscript, but the plugin id has changed slightly since the version used in this course:

group 'com.teamtreehouse'
version '1.0-SNAPSHOT'

buildscript {
    repositories{
        mavenCentral()
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE'
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web:2.0.1.RELEASE'
}

You can see more information at the Gradle Plugins website or the Spring Docs.

Hope this helps.

Thanks I got it to work somehow. I just left out the builder and it worked as is. appreciate your help.