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 Configuring Gradle for Spring Development

Spring-boot run error

Hi, My spring-boot does not run successfully. I have difference in application files in the video and on my IDE In the gradle tool window Giftlib>applications i have only one file where in video there are many.

Following is my code

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

buildscript { repositories { mavenCentral() } dependencies { // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-gradle-plugin classpath group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '1.5.1.RELEASE' } } apply plugin: 'java' apply plugin: 'spring-boot'

sourceCompatibility = 1.5

repositories { mavenCentral() }

dependencies { // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.1.RELEASE' } group 'com.godfather' version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.5

repositories { mavenCentral() }

dependencies { testCompile group: 'junit', name: 'junit', version: '4.11' }

THIS IS IN appconfig

package com.Godfather.giftlib;

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

@EnableAutoConfiguration public class AppConfig { public static void man (String[] args) {

    SpringApplication.run(AppConfig.class,args);
}

}

Tagging Craig Dennis

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Check this answer.

All is there. TL;DR;

DO NOT use buildscript with Gradle 3+ and spring-boot > 1.4

Example with plugins notations see in the answer above.

If answer there will not help, post the link to GitHub Project, so that I can reproduce error myself.

PS: Small note. Junit is better to be set 4.12 as well

As far as I remember, since SB 1.4 it complains that Junit dependencies has to be changed to AT LEAST 4.12

Awais Jamil
Awais Jamil
7,539 Points

i am totally stuck gradle is not working please help Error ( the supplied build acion faild with exception )