I am trying to use JTE template in Spring Boot 3.3 it is working during dev
environment. But during production (pre compilation) deploy it is failing. For some reason template is not being found and I am getting this error. Resource not found
. This is my build.gradle.kts
import kotlin.io.path.Path
plugins {
java
id("org.springframework.boot") version "3.3.0"
id("io.spring.dependency-management") version "1.1.5"
id("gg.jte.gradle") version("3.1.12")
}
group = "com.playpen"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_21
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("gg.jte:jte-spring-boot-starter-3:3.1.12")
implementation("gg.jte:jte:3.1.12")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks.withType<Test> {
useJUnitPlatform()
}
jte {
precompile()
sourceDirectory.set(Path("src/main/resources/templates"))
}
tasks.jar {
dependsOn(tasks.precompileJte)
from(fileTree("jte-classes") {
include("**/*.class")
include("**/*.bin") // Only required if you use binary templates
})
}
This is my TemplateConfiguration
import gg.jte.ContentType;
import gg.jte.TemplateEngine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
@Profile("prod")
class TemplateConfiguration {
@Bean
public TemplateEngine templateEngine() {
return TemplateEngine.createPrecompiled(ContentType.Html);
}
}
and here are my application.properties
gg.jte.templateLocation=src/main/resources/templates
gg.jte.templateSuffix=.jte
gg.jte.developmentMode=true
and application-prod.properties
gg.jte.usePrecompiledTemplates=true
gg.jte.developmentMode=false