JavaSpring或Javascript不会重新加载网页

时间:2020-05-27 06:04:25

标签: javascript spring spring-boot

我有这些奇怪的问题,我对HTML或Javascript文件所做的每项更改都不会反映在网页上。我不知道Spring boot是否是问题,老实说,我认为这不是问题,但我只是想确保不是问题。 顺便说一句,它过去每次都能工作。我在pom.xml上使用了依赖项devtool,它过去一直有效,每当刷新页面时,我都不必停止/启动Java spring应用程序。但是现在我所做的每一个改变都不会反映出来。我尝试了硬缓存重新加载先清除缓存然后重新加载,但这并不能反映出来。它仅反映了我停止Java Spring应用程序并更新Maven的时间,老实说我为什么必须这样做很奇怪。并在pom.xml中查看了我所有的版本后,即会更新。请参见下面的代码:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>dashboard.atmandcam</groupId>
    <artifactId>dashboardAtmAndCam</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
    </parent>

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

        <!-- jpa, crud repository -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

         <!--PostgreSQL -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </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>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>

        </plugins>

    </build>

</project>

1 个答案:

答案 0 :(得分:0)

您可以尝试以下依赖吗

 <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>

instead of 

  <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>