Fgop
Fgop

Reputation: 301

IntelliJ does not recompile/build maven project

I am running into problems when using IntelliJ for Spring development. At first, the IntelliJ build command works fine and picks up changes I make to the source code. At some point, this stops working and I can only compile my sources through maven, as the build or rebuild project commands seem to do nothing anymore.

I am confused, as it works as desired at the start but then stops working at some point.

Steps to recreate:

I tried a few things to overcome this problem, but without success:

Is anyone experiencing similar problems and/or has a solution?

Upvotes: 5

Views: 9554

Answers (3)

Kawu
Kawu

Reputation: 14003

I'm not 100% sure if I understood the entire problem. For me saving the files via Ctrl+S and then simply stopping/restarting the server didn't make the changes appear in the webapp until I opened the Project Settings -> Artifacts -> *.war/ear: exploded -> check "Include in project build".

enter image description here

Before that, I had to manually execute clean + package in the Maven tab, which is slow.

Upvotes: 0

joseph
joseph

Reputation: 2786

Sounds like do don't want Intellij's default build. You want Intellij to forward the build command to mvn. I assume this because you do not mention this step in your question.

Here's a screenshot that shows how to enable it:

delegate build and rebuild to mvn

More detail is available in the Intellij documentation https://www.jetbrains.com/help/idea/delegate-build-and-run-actions-to-maven.html#delegate_run_action

Upvotes: 7

Fgop
Fgop

Reputation: 301

So for anyone running into the problems I described above:

Apparently deleting the .idea folder and restarting IntelliJ does indeed do the trick. The folder is recreated on restart and afterwards I'm able to switch between compiling within IntelliJ using run, build or rebuild project and compiling through maven goals (mvn compile, mvn test, mvn surefire:test, ...). This persists through restarts of IntelliJ such that I don't have to repeat this everytime I open a project.

I still don't know why this behavior happens, but it's a solution I'm happy to work with as long as I only have to do it every now and then for a project.

Upvotes: 10

Related Questions