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-boot not found? Workaround here

For whatever reason the buildscript in the video produces an error, probably if you're not using java 1.5, as is the video. Answer below.

1 Answer

I'm using java 1.8, which may have caused an issue in refreshing gradle using the spring boot starter version specified in the video. Since I'm using a newer java I figured maybe I should be using a new spring boot starter (which could cause its own issues, we'll see I guess). I chose 1.5.10, but 2.0.0 is the latest as of the time of this writing. Then I went and found an example buildscript for version 1.5.10. Switch that to whatever version you are using.

The newer code looks like this:

buildscript {
  repositories {
    maven {
      url 'https://plugins.gradle.org/m2/'
    }
  }
  dependencies {
    classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE'
  }
}

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

Notice that

  • a full url is used for the repository as opposed to mavenCentral()
  • the classpath has a different version, which is reflected in the dependencies block farther down

Full buildscript

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

buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE'
    }
}

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

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

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