【问题标题】:I can't get springboot devtools to work我无法让 springboot devtools 工作
【发布时间】:2017-08-30 00:47:33
【问题描述】:

我正在使用 STS 3.8.4,我已将 spring devtools 依赖项放在我的 pom.xml 上,我尝试在 IDE 上运行我的 springboot 项目,转到一个页面(使用 thymeleaf 的模板)并尝试修改模板上的东西,我点击刷新但没有任何反应。是否需要其他配置?我还尝试将 thymeleaf 缓存设置为 false,但仍然没有运气。下面是我的 pom.xml。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.emil</groupId>
  <artifactId>inventory</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>inventory</name>
  <description>Inventory System in Spring</description>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath/>
    <!-- lookup parent from repository -->
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>


    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>

Log Log 2

【问题讨论】:

  • 您可能需要关闭 thymeleaf 的缓存。看到这个帖子stackoverflow.com/questions/43147157/…
  • 它不工作。我的 application.properties 看起来像这样。
  • spring.jpa.hibernate.ddl-auto=update spring.datasource.url= jdbc:mysql://localhost:3306/inventory spring.datasource.username= root spring.datasource.password = root spring.thymeleaf.cache=false
  • 您是否检查过您的浏览器是否正在缓存模板?在运行时尝试清除浏览器缓存并查看它是否更新
  • 试过了还是不行

标签: spring spring-boot spring-tool-suite


【解决方案1】:

我终于找到了解决办法。问题是我的 Eclipse 在保存时不会自动构建项目。

【讨论】:

    猜你喜欢
    • 2016-02-25
    • 2016-09-14
    • 2016-09-02
    • 2015-05-20
    • 2015-10-22
    • 2023-03-24
    • 2017-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多