What's the correct procedure to add JARs into WEB-INF/lib directory in IntelliJ
Solution 1
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.
Solution 2
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.
Solution 3
Create the WEB-INF
folder manually in your project’s file system.
If you want the added jar(s) to be part your web app, part of your WAR file, then you may need to manually add the WEB-INF
folder and nested lib
folder to your file system if you do not already see them. Ditto if you want WEB-INF/classes
to store anything such as Flyway database migration SQL scripts.
Once created, IntelliJ should auto-detect them and show in the project structure.
Even if you did not see these folders in your project structure, IntelliJ was likely creating them dynamically in packaging your web app at build-time. Anything you place in your manually created folders will be merged in alongside the other generated items being placed in the auto-generated WEB-INF
folder. Not obvious at all, but an effective process.
user1902183
Updated on June 14, 2022Comments
-
user1902183 almost 2 years
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?
-
Admin almost 6 yearsSpecially in IntelliJ