Java Intro to Java Web Development with Spark Diving into Web Development Sending Responses

Martin Gallauner
Martin Gallauner
10,806 Points

No Autoimport for HandlebarsTemplateEngine

Hi there

I followed Craig's instructions but somehow Intellij don't want to Autoimport the HandlebarTemplateEnginge class and I have no idea what I'm missing. The handlebar/mustache Plugin is installed.

This is how my dependencies look like:

dependencies { compile "com.sparkjava:spark-core:2.6.0" compile 'com.sparkjava:spark-template-handlebars:2.5.5' compile 'org.slf4j:slf4j-simple:1.7.21' testCompile group: 'junit', name: 'junit', version: '4.12' }

I made a Screenshot, I hope that helps.

Thanks

2 Answers

Trent Christofferson
Trent Christofferson
15,399 Points

Make sure you have already created it :). Assuming it is there make sure the class is not private or, if it is not in the same package, make sure it is not package-private (where it is usually public, there is nothing there). Another issue could be the class's initializer. Make sure that is accessible from where you're trying to access it.

Martin Gallauner
Martin Gallauner
10,806 Points

Thanks for you fast reply Trent! I didn't created it since it should be a dependency from the spark framework. But I'm not sure about this

Sławomir Lasik
Sławomir Lasik
7,792 Points

Try to add

import spark.ModelAndView;
import spark.template.handlebars.HandlebarsTemplateEngine;

above

import static spark.Spark.get;

If it works it is something with intellij. That tool is still a bit mystery for me.