简体   繁体   English

Maven2 IDEA项目,如何手动添加到web-inf/lib文件夹?

[英]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?使用 intelliJ IDEA,如何手动将 .jar 添加到我的 web-inf/lib 文件夹?

It is a maven project and I have been adding .jar's via pom.xml thus far.这是一个 maven 项目,到目前为止我一直在通过 pom.xml 添加 .jar。

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.我手动删除了 .jar,但它似乎没有选择 .jar,因为当我添加导入语句等时它没有选择命名空间。

Add the WEB-INF/lib directory to your project libraries.将 WEB-INF/lib 目录添加到您的项目库中。

Ctrl-Shift-Alt-S, then choose "Libraries" and attach your WEB-INF/lib as a JAR directory. Ctrl-Shift-Alt-S,然后选择“Libraries”并将您的 WEB-INF/lib 作为 JAR 目录附加。 Every JAR in that directory will be added to CLASSPATH for compilation.该目录中的每个 JAR 都将添加到 CLASSPATH 以进行编译。

Obviously, WEB-INF/lib JARs are automatically in CLASSPATH when you run a WAR file, so you're fine at runtime.显然,当您运行 WAR 文件时,WEB-INF/lib JAR 会自动位于 CLASSPATH 中,因此您在运行时没问题。

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.如果您使用 Maven,则不会这样做(因为 Maven 不会意识到它),您在 POM 中添加依赖项并让 IDE 从中派生项目配置。 What's the point of using Maven if you can't build your code with it?如果您无法使用 Maven 构建代码,那么使用 Maven 有什么意义? So either use Maven and add the dependency to the pom.xml or... don't use it.所以要么使用 Maven 并将依赖项添加到pom.xml要么...不要使用它。

In Intellij IDEA right click on WEB-INF/lib directory and choose "Add as Library..." Worked for me.在 Intellij IDEA 中右键单击 WEB-INF/lib 目录并选择“添加为库...”对我有用。 Hope it helps!希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Intellij IDEA中复制maven依赖项以输出工件WEB-INF / lib? - How to copy maven Dependencies to ouput artifact WEB-INF/lib in Intellij IDEA? 为什么在Eclipse中构建Maven项目后,“WEB-INF / lib”文件夹显示为空? - Why does “WEB-INF/lib” folder appear to be empty after a Maven project is built within Eclipse? 我的Maven项目没有将依赖项导入WEB-INF / lib文件夹 - My maven project does not import dependencies to WEB-INF/lib folder Maven不会在WEB-INF / lib文件夹中复制spring jars - Maven does not copy spring jars in WEB-INF/lib folder Maven构建损坏/ WEB-INF / lib文件夹中的jar文件 - Maven build corrupting jar files in /WEB-INF/lib folder 在WAR的WEB-INF / lib文件夹中重命名Maven依赖项 - Renaming Maven dependency in WAR's WEB-INF/lib folder 如何将罐子从WEB-INF / lib复制到Maven战争中的另一个文件夹 - how to copy jars from WEB-INF/lib to another folder in war in maven 在Eclipse中,如何在WEB-INF / lib文件夹下添加jar文件夹? - In Eclipse, how to add a folder of jars under WEB-INF/lib folder? 如何将 JAR 文件添加到 Eclipse 中的 web-inf/lib 文件夹? - How can I add JAR files to the web-inf/lib folder in Eclipse? 如何将 JAR 文件添加到现有的 WAR 文件 web-inf/lib 文件夹中? - How to add JAR file to an existing WAR file web-inf/lib folder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM