简体   繁体   中英

Maven2 IDEA project, how to manually add to web-inf/lib folder?

With intelliJ IDEA, how do I manually add a .jar to my web-inf/lib folder?

It is a maven project and I have been adding .jar's via pom.xml thus far.

I manually dropped the .jar, but it didn't seem to pick up the .jar since it doesn't pick up the namespace when I add a import statement etc.

Add the WEB-INF/lib directory to your project libraries.

Ctrl-Shift-Alt-S, then choose "Libraries" and attach your WEB-INF/lib as a JAR directory. Every JAR in that directory will be added to CLASSPATH for compilation.

Obviously, WEB-INF/lib JARs are automatically in CLASSPATH when you run a WAR file, so you're fine at runtime.

If you use Maven, you don't do that (since Maven wouldn't be aware of it), you add dependencies in the POM and let the IDE derive the project configuration from it. What's the point of using Maven if you can't build your code with it? So either use Maven and add the dependency to the pom.xml or... don't use it.

In Intellij IDEA right click on WEB-INF/lib directory and choose "Add as Library..." Worked for me. Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM