2016-05-17 136 views
3

我正在開發一個使用IntelliJ IDEA 15和tomcat的AngularJS和Spring啓動應用程序,每當我對靜態內容進行更改時,我總是重新啓動應用程序以查看這些更改。Intellij IDEA - 自動重新加載web應用程序

我找了一個類似的問題,我發現這一點:

Enable IntelliJ hotswap of html and javascript files

但我不能找到任何地方Update resources選項:

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> 
+0

可以參考http://stackoverflow.com/a/43234019/1629278也許它有幫助。 –

回答

1

在春季啓動應用程序如果包括彈簧引導devtools模塊的依賴性的一個,它可以給你額外的功能,例如當文件在類路徑上改變時自動重啓應用程序。

如果使用搖籃

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

由於您使用IntelliJ觸發自動重啓你需要讓項目(Build -> Make Project)(按Ctrl + F9在Windows上)

添加下面的依賴

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

欲瞭解更多信息,請訪問here

有關在何處添加靜態內容的更多信息 - >here

+0

我害怕說它沒有工作,在做完項目之後我該如何運行它,我'在我的情況下使用Shift + 10,但我不能看到我刷新我的HTML頁面時所做的修改,我也檢查了maven的依賴關係和'spring-boot-devtools'有沒有 –

+0

你可以放置目錄結構..你的包裝是什麼。 .jar還是戰爭? –

+0

注意Shift + F10不是製作項目的默認鍵盤映射 –

相關問題