In this short article, we would like to show how in a proper way configure IntelliJ IDE when we use multi-module maven project and we have a problem with access to resources and *.jsp files in Spring Boot Application.
Set working directory for run module:
1. go to Run/Debug Configurations:
Run -> Edit Configurations... -> Spring Boot -> [my spring boot application] -> Configuration -> Environment
2. set Working directory as:
1. Problem overview
When we use maven modules in the project and the application is run from:
- the command line, everything works well
Note: we run
java -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.
@Autowired ResourceLoader resourceLoader; ... Resource someResource = resourceLoader.getResource("some_resource.txt");
2. Problem solution
It is necessary to select the correct working directory for the run module.
- 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
- accept all changes