Say I have a Java web project and I need to place a couple of JARs into the WEB-INF/lib directory. In Eclipse, if you simply place those JARs there, Eclipse picks them up as on the classpath. However, IntelliJ doesn't seem to.
What is the correct way of adding those JARs into the project such that they are in the standard WEB-INF/lib directory?
From the main menu, select File | Project Structure | Project Settings | Modules. Select the module for which you want to add a library and click Dependencies. button and select Library. In the dialog that opens, select a project or a global library that you want to add to the module.
From the main menu, select File | Project Structure Ctrl+Alt+Shift+S and click Artifacts. Click. , point to JAR, and select From modules with dependencies. To the right of the Main Class field, click.
In the Project Structure window, after adding the JAR in the section "Libraries", you can go to the section "Artifacts" and you'll see in the register "Output Layout" how the WEB-INF folder will look like. On the right side you see "Available Elements", which you can drag&drop to the left site into the lib folder.
The only way i could do this is by adding the required jars manually to the WEB-INF/lib folder on the file system and add that to project library explicitly (apart from the way to add via module library as described in the linked SO question).
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With