Hi guys, I'm a new Java Web Developer, and I'm so frustrated those days about working on Spring, Gradle and IDEA...
I simply want to write code in IDEA, use Gradle to solve dependencies and build (compile classes and generate a war file), click one button to compile (incrementally) compile all my codes and deploy them on the server, or on click to run all tests. I didn't work with Spring Boot because the embeded tomcat is outdated.
So I'm wondering the best practice to organize the project.
- I created a Gradle Project, because I can add Spring MVC facet in the module settings while I don't know how to add Gradle support after created the project.
- I opened the module setting, add `Web` and `Spring` then `Spring MVC` (The Spring MVC won't appear unless I select Spring first) facet. Later I received an alert that I should add all of them into `Artifacts`. I clicked fix all (seems all libraries are added to the generated layout) and apply, then the IDEA told my it can't resolve symbols of imported libraries, the External Libraries tab is empty now. I can't make the project (this is another problem) though I can run `./gradlew bulid` successfully.
- I re-ran `./gradlew idea` from the command line again, and those jar file appeared in the External Libraries again. I didn't add the lib directory in the project to the module settings' Library tab. I can `Make` the project now. But the Make generate those classes in `out` directory, while Gradle Build generate the classes in the `build` directory.
- In the `Run/Debug Configuration` dialog, I added an Tomcat Server, but the `before launch` has only two option: Make, Build artifact. The Tomcat Server runs successfully.
In fact, what I want is that
- The IDEA can resolve the Gradle dependencies automatically, and resolve symbols.
- I click run server, it will calls Gradle build (incrementally build).
- Deploy those classes into the Tomcat Server by Hot swapping.
Or may I ask how you do those things in your workspace? I'm hunting for a convenient best practice.