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

Can't get HandlebarsTemplateEngine to work - January 2022

I'm getting multiple errors trying to follow along with this course. It seems wildly outdated, as every video I cannot follow along. It's extremely frustrating.

Does anyone know how to make HandlebarsTemplateEngine work in 2022?

I'm getting an error on: import spark.template.handlebars.HandlebarsTemplateEngine;

that says "cannot resolve symbol 'template'

2 Answers

If you are using gradle, in build.gradle,

dependencies {
    implementation "com.sparkjava:spark-template-handlebars:2.7.1"
}

If you are using maven, in pom.xml,

        <dependency>
            <groupId>com.sparkjava</groupId>
            <artifactId>spark-template-handlebars</artifactId>
            <version>2.7.1</version>
        </dependency>

Gradle did not build successfully for me until I updated my IDE and in the process updated gradle to gradle 7.3

Thanks, I ended up with implementation group: 'com.sparkjava', name: 'spark-template-handlebars', version: '2.7.1'

But it didn't work until I restarted IntelliJ completely.