Spring boot + thymeleaf in IntelliJ: cannot resolve vars

后端 未结 8 1273
清酒与你
清酒与你 2021-02-05 02:44

I\'m writing a short web form application using spring boot and thymeleaf on IntelliJ, but it seems that in the html file, all fields in the model cannot be resolved. Here is my

8条回答
  •  無奈伤痛
    2021-02-05 03:19

    In my case the problem was that I had the following in my application.properties:

    spring.thymeleaf.prefix=file:src/main/resources/templates/
    
    spring.thymeleaf.cache=false
    

    Once I removed these properties, the spring mvc mappings are detected by Intellij again (in the Ultimate version, I'm using 2018.1). Also the thymeleaf objects are working now.

    I used these properties to support fast development where a refresh would reload the thymeleaf template files.

    To solve this issue, I use the following -D option in my run configuration of my spring boot application to tell spring boot where my property files are during development:

    -Dspring.config.location=/dev/application/conf/application.properties
    

提交回复
热议问题