angularjs - Intellij IDEA – 自动重新加载 Web 应用程序

标签 angularjs intellij-idea spring-boot

我正在使用 IntelliJ IDEA 15 和 tomcat 开发 AngularJS 和 Spring 引导应用程序,每当我对静态内容进行更改时,我总是会重新启动我的应用程序以查看这些更改。

我找了一个类似的问题,我发现了这个:

Enable IntelliJ hotswap of html and javascript files

但是我在任何地方都找不到更新资源选项:

enter image description here

编辑:

这是我的项目结构:

enter image description here

这是我的 pom 文件:

<?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>org.***.***</groupId>
    <artifactId>***_project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>***_PROJECT</name>
    <description>***Project</description>

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

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-social-facebook</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>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </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-starter-mail</artifactId>
        </dependency>
        <!-- spring security dependency -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <!-- end spring security dependency -->
         <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.0</version>
         </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

</project>

最佳答案

在 Spring Boot 应用程序中,如果您将 spring-boot-devtools 模块作为您的依赖项之一,它可以为您提供额外的功能,例如每当类路径上的文件更改时自动重启应用程序。

添加如下依赖

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

如果使用 Gradle

dependencies {
    compile("org.springframework.boot:spring-boot-devtools")
}

由于您正在使用 IntelliJ 来触发自动重启,因此您需要 Make Project ( Build -> Make Project )(Windows 上为 Ctrl + F9)

欲了解更多信息,请访问 here

有关在何处添加静态内容的更多信息 -> here

关于angularjs - Intellij IDEA – 自动重新加载 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37280605/

相关文章:

javascript - 将方法绑定(bind)到数组中的每个项目

java - 在 Intellij 中我无法停靠项目窗口

spring - 如何在 spring boot 中使用 mockito 模拟 deleteById

java - 当绑定(bind)访问 YAML 文件时,抛出 NullPointPointer

intellij-idea - intellij 中的自定义评论标记

spring-boot - 没有 OAuth 的 Spring 安全 JWT

java.sql.SQLIntegrityConstraintViolationException : Duplicate entry '0' for key 'PRIMARY'

angularjs - 在 AngularJS 中缓存 HTTP 'Get' 服务响应?

javascript - Angular Js 路由无法正常工作

javascript - 如何从 angular2 项目访问 "$wakanda"服务以检索数据?