0

I have a web application. I mostly used notepad++ for development. I need to use Intellij to run two Tomcat servlets. My ideal set up is to run the two serlets in IntelliJ and then minimise and never use intellij again (i.e. make my changes in notepad++, save. then just refresh my browser tab).

To stop myself from having to rerun the servlets every time I make a code change, I set up springboot devtools and added configuration below:

I followed this link: https://dzone.com/articles/spring-boot-application-live-reload-hot-swap-with (had to alter the first step to do the same thing but with gradle i.e. add

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

to the gradle.build (the correct one, not any random one).

then after finishing the rest of the steps from the link, added this line to application.properties:

spring.thymeleaf.cache= false

THEN when running the tomcat servlets in DEBUG mode

After doing all of the above, this works by: when servlets are running in intellij -make your UI code change -save it (in my case i was using notepad++ not intellij - go back to intellij (just bring the window into focus) - then go back to browser and refresh the browser

Currently, my code changes will only be applied if I bring the Intellij window into focus before refreshing my browser. Is it possible to set something up so intellij doesn't need to be in focus?

i.e. open intellij, run my two servlets, then minimise it and never touch it again. I want to ignore it and carry on just using my browser and notepad++ for dev work

user3120554
  • 641
  • 2
  • 11
  • 21
  • Wouldn't it be easier if you just used IntelliJ? But to answer your question, it's probably not possible. The link you followed made you configure IntelliJ so it would automatically make when it detects a change. **However**, IntelliJ most likely will only detect a change when that change is made in IntelliJ itself. It will reload from disk once in a while, but I guess that only happens when the window is active to reduce CPU and I/O usage. If you made the changes directly in IntelliJ itself, you wouldn't have this problem. – g00glen00b Aug 03 '17 at 09:11

2 Answers2

0

This isn't possible as far as I know. The Spring boot Devtools will hot reload as soon as the project is built.

In IntelliJ, the project won't automatically rebuild, but this can be configured by enabling Build project automatically (compiler.automake.allow.when.app.running).

However, even when you enable this, IntelliJ will only build it automatically if it detects a change. If you change a file in IntelliJ, this will count as a change. However, when you change a file in another editor like Notepad++, it won't.

Luckily, IntelliJ synchronizes files from disk at certain times. By default, IntelliJ is configured with Synchronize files on frame or editor tab activation, so it will synchronize the files as soon as an editor is opened.

This is what you're experiencing. However, you can't change synchronization to always happen since that would require quite some I/O and CPU.There are some plugins like the Auto Sync plugin, that may allow you to customize when the synchronization happens.

Alternatively, if you edit the files in IntelliJ (and not in Notepad++), you wouldn't need to synchronize, and thus you wouldn't have this problem.

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
  • Ah this makes sense. The main reason I didn't want to use IntelliJ was because it seems very RAM intensive. If I had many files open, I expected it to just freeze over – user3120554 Aug 03 '17 at 09:25
  • @user3120554 in that case you may want to look for more lightweight Java editors or if it's possible to do this in Notepad++. Basically all you need is a good integration that will rebuild the source files as soon as you change something. – g00glen00b Aug 03 '17 at 09:37
0

I found this in one tutorial, This is what u can do..

Settings --> Build-Execution-Deployment --> Compiler --> enable "Make Project Automatically".
Restart IntelliJ.

In earlier version of IntelliJ

Press ctrl+shift+A and search for the registry. Enable following configuration compiler.automake.allow.when.app.running

Read: https://dzone.com/articles/spring-boot-application-live-reload-hot-swap-with

<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-devtools</artifactId>
</dependency>
Kul Bhushan Prasad
  • 859
  • 3
  • 12
  • 19