且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Spring Boot 1.3,当在Netbeans中进行更改时,spring-boot-devtools和Thymeleaf模板将不会实时重新加载

更新时间:2021-10-02 17:56:15

将Netbeans项目属性中运行项目操作"中的执行目标"更改为以下内容:

Change Execute goals in Run project Action in Netbeans project properties to the following:

process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 代替package spring-boot:run启用Spring Boot Devtools并按预期方式重新启动.

process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec instead of package spring-boot:run enables Spring Boot Devtools and restart works as expected.

Thymeleaf模板的问题归因于以下事实:在Spring Boot 1.3中,Spring Boot Maven插件不再将src/main/resources直接添加到类路径中. 有关详细信息,请参见发行说明

Problem with Thymeleaf templates was attributed to the fact that in Spring Boot 1.3, The Spring Boot Maven plugin no longer adds src/main/resources directly to the classpath. See release notes for details.

为pom.xml配置显式资源目录位置(在我的情况下为src/main/resources)解决了Thymeleaf模板不重新加载的问题:

Configuring explicit resource directory location (in my case src/main/resources) to pom.xml resolves the problem with Thymeleaf templates not reloading:

<build>
   ...
   <resources>
     <resource>
       <directory> src/main/resources </directory>
     </resource>
   </resources>
  ... 
 </build>