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 trialChristiaan Quyn
14,706 PointsCan not use the @RequestBody annotation and get the standard Whitelabel Error Page on my localhost:8080
So here are my java class files and gradle.build file , what am I missing - would greatly appreciate finding out what I am doing wrong. Cheers
GifController.java
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by Christiaan on 27/05/2016.
*/
@Controller
public class GifController {
@RequestMapping("/")
@RequestBody
public String listGifs() {
return "List of all the Gifs";
}
}
AppConfig.java
package com.kpqventures.giflib;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
/**
* Created by Christiaan on 26/05/2016.
*/
@EnableAutoConfiguration
@ComponentScan
public class AppConfig {
public static void main(String [] args) {
SpringApplication.run(AppConfig.class, args);
}
}
giflib
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
// tag::jetty[]
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
// end::jetty[]
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
Christiaan Quyn
14,706 PointsSorry guys I solved it , wow I feel like such a idiot. This is the 2nd time I've done this , lose my mind over an error , post it on the forum only to find out it was a silly mishap later during the day. I typed in @RequestBody instead of @ResponseBody .. urgh ! Then ran into a bunch of gradle errors that refused to compile the program until I Restarted and Invalidated Caches from the drop down file menu.
Sorry again
2 Answers
Steve Hunter
57,712 PointsHi Christiaan,
Glad you got it fixed!
Steve.
yusuf limdiwala
1,328 PointsHi Steve i have implemented the same way as shown in the video but my bootRun is taking alot of time and even then i am not seeing any server starting msges. what should i do ?
yusuf limdiwala
1,328 PointsSteve Hunter Sorry for the Trouble. its all working fine . in IntelliJ IDEA the Toggle tasks executions/text mode was not Enable.
Steve Hunter
57,712 PointsGlad you got it fixed!
Christiaan Quyn
14,706 PointsChristiaan Quyn
14,706 PointsHi Chris Ramacciotti , Steve Hunter would greatly appreciate any advice on this :D Thanks in advance !