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 Intro to Java Web Development with Spark Diving into Web Development Sending Responses

chaim Wilmowsky
chaim Wilmowsky
695 Points

HandlebarsTemplateEngine() not recognized by intellij. whats going on?

i get a red line saying it dosnet know what HandlebarsTemplateEngine() is. i did install it.

5 Answers

Nicholas Pretorius
Nicholas Pretorius
18,683 Points

Hi,

I had a similar problem - I did the following (Mac running IntelliJ IDEA Community 2017.1):

  1. Refreshed Gradle
  2. Restarted IntelliJ
  3. Restarted my Mac
  4. Deleted the get() declaration with the error and rewrote it from scratch

While I don't think steps 2 & 3 are necessary, deleting the original offending line and rewriting it seemed to do the trick.

Hope this helps

Jeremiah Shore
Jeremiah Shore
31,168 Points

Running Windows7, IntelliJ IDEA Community 2017.1... having a similar issue; IntelliJ will not detect spark for auto-import. I've done this course before with no issues when previously using a 2015 version, so I'm not sure what's up this time. I'm running the course as a refresher to get back into the JWD Techdegree soon (hopefully).

I tried rebuilding, refreshing Gradle, etc. Also found out that sometime when I upgraded to 2017 from 2015 that my Maven plugin was disabled; came across that as part of this troubleshooting effort. I fixed that and repeated the earlier steps with no change. What's weird is I can manually type out the import statements; the libraries are synced with Gradle and are part of the project, it just won't auto-import.

Any thoughts? Craig Dennis

Carmine Sarno
Carmine Sarno
19,660 Points

The shorthand Gradle notation wasn't working for me either (IntelliJ 2017). Try commenting out the shorthand Handlebars line in build.gradle and replacing it with: compile group: 'com.sparkjava', name: 'spark-template-handlebars', version: '2.5.5'

Refresh Gradle and it should work.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Did you refresh Gradle afterwards?

Awais Jamil
Awais Jamil
7,539 Points

i have the error :

Could not find method compile() for arguments [com.sparkjava:spark-template-handlebars;2.3] on object of type org.gradle.api.internal............

please help

Rishi Gupta
PLUS
Rishi Gupta
Courses Plus Student 2,466 Points

For some reason I had to do

import spark.template.handlebars.HandlebarsTemplateEngine;

Refreshing Gradle, restarting IntelliJ, etc didn't seem to work. This is using Intellij 2017 also.

I think this course should be updated, there is to many issues that is take the learning experience away