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 Spring Components and Configuring Our App Adding a Spring Configuration File

Getting "FAILURE: Build failed with an exception." when run bootRun

I kept getting the follow error message. And i have no idea how to fix it.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':findMainClass'. > org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;

6 Answers

zack wooters
zack wooters
4,536 Points

Try this for your build.gradle

plugins { id 'java' id 'idea' id 'eclipse' id 'org.springframework.boot' version '2.1.7.RELEASE' }

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

sourceCompatibility = 1.8

repositories { mavenCentral() }

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

I am able to verify that Zack Wooter's suggestion is correct. If you would like a formatted config here you go:

COPY EVERYTHING BELOW THIS LINE

plugins {
    id 'java'
    id 'idea'
    id 'eclipse'
    id 'org.springframework.boot' version '2.1.7.RELEASE'
}

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

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web:2.1.7.RELEASE'
}
Zwea Htet
Zwea Htet
4,001 Points

Thanks, Zack! It works for me.

Please post code so we can see what's wrong with it

Hi Tom, Please see code and error message below.

package com.teamtreehouse;

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

@EnableAutoConfiguration public class AppConfig { public static void main (String[] args) { SpringApplication.run(AppConfig.class, args); } }

error message: 3:19:43 PM: Executing task 'bootRun'...

Gradle Daemon started in 6 s 287 ms

Task :compileJava UP-TO-DATE Task :processResources NO-SOURCE Task :classes UP-TO-DATE Task :findMainClass FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':findMainClass'. > org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;

*

Murilo de Melo
Murilo de Melo
14,456 Points

I searched the Internet and saw that this is kind of a bug in this version of IntelliJ. I tried other RELEASE versions in the official website, but it just got worse. No progress with bootRun. Whatever that is, it's really frustrating because there are hundreds of exhausting explanations for dozens of different scenarios and a lot of jargon. All that distracted me and at the end I did nor understand anything anymore, what I thought I was getting. For beginners I would say it's demotivating. I love the courses at TreeHouse, but for the first time, this one, after hours of watching as a complementary of other web dev courses, making tons of notes, and searching, I came to this problem where I could not go further. I just gave up this course because I really need to learn this quickly and had no more motivation or energy due to that, no effective response and no solution found on my own. And believe me, I don't give up easily. Just to be honest. I'm trying now Spring in Eclipse, doing another course. Happy so far.

I also tested with newer release. It didnt work.

Claudiu Haidu
Claudiu Haidu
3,909 Points

This confiration worked

Just faced this issue myself and with using the config Matthew Endicott had sent I also had to Run giflib [dependencies] (i.e. the play button near the dependencies {} section at the bottom of build.gradle. I then I was able to run giflib [bootRun]