You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Quarkus 1.2.0.FINAL版本Qute模板无法解析问题求助

Troubleshooting Qute Template Not Found in Quarkus 1.2.0.FINAL

I’ve run into similar quirks with older Quarkus versions and Qute, so let’s walk through the most likely culprits and fixes for your scenario:

1. Missing Configuration for Non-HTML Template Suffixes

Quarkus 1.2.x’s Qute implementation only scans for .html templates by default. Since your template uses a .txt extension, the framework isn’t picking it up unless you explicitly tell it to include .txt files.

To fix this:

  • Add the following line to your application.properties file:
    quarkus.qute.suffixes=html,txt
    
  • Keep your @ResourcePath annotation using the template name without the suffix (the configured suffix list will handle matching):
    @Inject
    @ResourcePath("startTemplate")
    Template startTemplate;
    

2. Gradle Resource Packaging Issues

Sometimes custom Gradle configurations can exclude or miss the templates directory, or cached builds can prevent fresh resources from being packaged.

Check these points:

  • Open your build.gradle and confirm you haven’t excluded the templates directory in your source sets. Your resources section should look like this (no exclusions for templates):
    sourceSets {
        main {
            resources {
                srcDirs = ["src/main/resources"]
                // Avoid lines like exclude 'templates/**'
            }
        }
    }
    
  • Run ./gradlew clean build to clear cached artifacts—old cached resources often cause templates to go missing in the final jar.
  • Inspect your built jar file (look inside BOOT-INF/classes/templates/) to verify startTemplate.txt is present. If it’s missing, your Gradle config is the root issue.

3. Non-CDI Managed Bean

Quarkus can only inject Qute Templates into CDI-managed beans. If your LifecycleBean doesn’t have a CDI scope annotation (like @ApplicationScoped, @Singleton, or @RequestScoped), the @ResourcePath injection won’t work at all.

Fix this by adding a scope annotation to your bean:

@ApplicationScoped
public class LifecycleBean {
    @Inject
    @ResourcePath("startTemplate")
    Template startTemplate;

    // Rest of your code
}

4. Known Bugs in Quarkus 1.2.0.FINAL

Quarkus 1.2.0.FINAL is an old release (early 2020), and there were several Qute-related bug fixes in the subsequent 1.2.x minor releases.

Consider upgrading to the latest 1.2.x version (1.2.1.FINAL) to see if the issue resolves itself. If you’re able to make larger changes, moving to a newer Quarkus major version (like 2.x or 3.x) would give you a much more stable and feature-rich Qute implementation.


内容的提问来源于stack exchange,提问作者Snappawapa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 16:07:34