Spring Boot没有更新静态html(使用Kotlin / Intellij) [英] Spring Boot not updating static html (with Kotlin/Intellij)
问题描述
我使用Spring Boot,Kotlin和Intellij构建了一个非常简单的静态内容Web服务器。我运行我的程序,它正确地在localhost:8080上提供我的html。但是,如果我在服务器运行时更新该html,则强制在浏览器中重新加载页面,我的更改永远不会显示。我读了很多可能是问题的东西。有关百万美元缓存的事情。 Spring Boot Devtools。 Intellij自动构建或其他东西。似乎没什么用。也许我的代码上额外的一组眼睛可以找到我错过的东西。
I built a pretty simple static content web server using Spring Boot, Kotlin and Intellij. I run my program and it properly serves my html on localhost:8080. However, if I update that html while the server is running then force reload the page in the browser my changes are never shown. I've read a bunch of things that could be the problem. Something about thymeleaf cache. Spring Boot Devtools. Intellij auto builds or something. Nothing seems to work. Maybe an extra set of eyes on my code could pick up something I'm missing.
这是我的build.gradle
Here's my build.gradle
buildscript {
ext.kotlin_version = "1.2.0"
ext.httpcomponents_version = "4.5.4"
ext.springframework_version = "1.5.9.RELEASE"
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springframework_version"
}
}
group "com.atomicslurry"
version "1.0"
apply plugin: "java"
apply plugin: "kotlin"
apply plugin: "spring-boot"
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.apache.httpcomponents:httpclient:$httpcomponents_version"
compile "org.apache.httpcomponents:fluent-hc:$httpcomponents_version"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.2"
compile "org.springframework.boot:spring-boot-starter-thymeleaf:$springframework_version"
compile "org.springframework.boot:spring-boot-devtools:$springframework_version"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
这是我的kotlin app main
Here's my kotlin app main
package com.atomicslurry.sentinel
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
open class App
fun main(args: Array<String>) {
SpringApplication.run(App::class.java, *args)
}
最后,我的静态html在src / main / resources / static
Finally, my static html is in src/main/resources/static
有什么想法吗?
推荐答案
适用于我的一般工作流程:
The general workflow that is working for me:
- 编辑HTML
- 在IntelliJ中按Build Project(Ctr + F9),然后等到更改完成
- 转到浏览器并刷新
这篇关于Spring Boot没有更新静态html(使用Kotlin / Intellij)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!