3

I'm developing an AngularJS and Spring boot application using IntelliJ IDEA 15 and tomcat, whenever I make changes to my static content I've always to restart my application to see those changes.

I looked for a similar problem and I have found this :

Enable IntelliJ hotswap of html and javascript files

But I cant find Update resources option anywhere :

enter image description here

Edit :

This is my project structure :

enter image description here

And this is my pom file :

<?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>
Community
  • 1
  • 1
Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191

2 Answers2

1

In Spring Boot application if you include spring-boot-devtools module as one of your dependency, it can give you additional feature like automatically restart the application whenever files change on classpath.

Add the following dependencies

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

if using Gradle

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

Since you are using IntelliJ to trigger automatic restart you need to Make Project ( Build -> Make Project ) (Ctrl + F9 on Windows)

For more information visit here

More information regarding where to add the static content -> here

A0__oN
  • 8,740
  • 6
  • 40
  • 61
  • I'm afraid to say that it didn't work, after making the project how do I have to run it, I'm using Shift+10 in my case but I cant see the modification that I've made when I refresh my html page, I also checked the maven dependencies and `spring-boot-devtools` is there – Renaud is Not Bill Gates May 17 '16 at 15:56
  • Can you place the directory structure.. what is your packaging. .jar or war? – A0__oN May 17 '16 at 15:58
  • And note Shift + F10 is not the default Keymap for Make Project – A0__oN May 17 '16 at 16:01
  • My packaging is .jar and I'm using an embedded tomcat server in my spring boot application, for Shift + F10 is used to run the project not to make it, so what I do is I make the project and then I run it – Renaud is Not Bill Gates May 17 '16 at 16:03
  • If you are using jar please go through http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc-static-content to check if you placed you static content properly. And to make the project you can use Keymap Ctrl + F9 – A0__oN May 17 '16 at 16:07
  • I've added my project structure and my pom file, please check the modifications – Renaud is Not Bill Gates May 17 '16 at 16:11
  • Did you try to Make Project – A0__oN May 17 '16 at 16:18
0

I would suggest you to use Spring BOOT's Developer Tools library (LiveReload feature). This gives you the ability to restart a project automatically whenever something changes on a classpath

Documentation --> http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html

Srikanta
  • 1,145
  • 2
  • 12
  • 22