Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java

Gene Higgins
Gene Higgins
16,580 Points

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

Gene Higgins
Gene Higgins
16,580 Points

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'
}