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 Creating Controllers and Views Create a Controller to Handle HTTP Requests

Vaibhav Yaramwar
PLUS
Vaibhav Yaramwar
Courses Plus Student 4,292 Points

Showing Build failed what to do?

When I am running application it is showing build failed below are my java files :

AppConfig.java

package com.teamtreehouse.giflib;

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan;

@EnableAutoConfiguration @ComponentScan public class AppConfig {

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

}


GIFController.java

package com.teamtreehouse.giflib.Controller;

import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;

@Controller public class GifController {

@RequestMapping("/")
@ResponseBody
public String listGifs() {
    return "List of all the GIFs!";
}

}

build.gradel :

package com.teamtreehouse.giflib.Controller;

import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;

@Controller public class GifController {

@RequestMapping("/")
@ResponseBody
public String listGifs() {
    return "List of all the GIFs!";
}

}

Vaibhav Yaramwar
Vaibhav Yaramwar
Courses Plus Student 4,292 Points

Guys It is working properly now..... For Future Reference of anyone Below problem is occurred in my code :

8080 port was already used by Oracle and hence it is not allowing my Spring boot code to run.for this you need to create application.properties file in src/main folder and in that change server.port=9090 (9090 is just a example)