EN
Spring Boot - multi module maven doesn't see resources and JSP files under IntelliJ Ultimate
11 points
In this short article, we would like to show how in a proper way configure IntelliJ Ultimate IDE when we use multi-module maven project and we have a problem with access to resources and *.jsp files in Spring Boot Application.
Quick solution:
Set working directory for run module:
1. go to Run/Debug Configurations:
xxxxxxxxxx
1Run -> Edit Configurations... -> Spring Boot -> [my spring boot application] -> Configuration -> Environment
2. set Working directory as:
$MODULE_WORKING_DIR$
When we use maven modules in the project and the application is run from:
- the command line, everything works well
Note: we runjava -jar /path/to/application.jar
- IntelliJ IDE everything works well but it is impossible to:
- use *.jsp views with controllers that are needed when we use Tomcat as a server,
- read resources, e.g.
xxxxxxxxxx
12ResourceLoader resourceLoader;
3
4...
5
6Resource someResource = resourceLoader.getResource("some_resource.txt");
It is necessary to select the correct working directory for the run module.
Simple steps:
- click to Run -> Edit Configurations... menu,
- go to Spring Boot -> [my spring boot application] section in the left tree,
- go to Configuration tab,
- go to Environment configuration,
- set Working directory as
$MODULE_WORKING_DIR$
, - accept all changes
Screenshot:
