是否最好将项目jar文件Maven化或将它们放在WEB-INF / lib中? [英] Is it best to Mavenize your project jar files or put them in WEB-INF/lib?
问题描述
我一直在为我的Spring MVC项目需要的所有jar文件执行此操作:
I've been doing this for all of the jar files that my Spring MVC project needs:
call mvn install:install-file -DgroupId=vegetables -DartifactId=potatoes -Dversion=1.0 -Dfile=vegetables-1.0.jar -Dpackaging=jar -DgeneratePom=true
最近我必须超出你可以在 pom.xml
文件中列出的依赖项的数量上限,因为我收到一条错误消息:
Recently I must have exceeded some limit on how many dependencies you can list in your pom.xml
file because I got an error that said:
Your command line is too long
所以我删除了我的项目不再使用的 pom.xml
中的一些依赖项,我能够再次使用maven运行项目。
So I removed some dependencies from the pom.xml
that my project no longer uses and I was able to run the project with maven again.
我的问题是,我应该将所有jar文件安装到我的Maven资源库中吗?或者我应该将其中一些放入 WEB-INF / lib
目录?
My question is, should I put install all jar files into my Maven repository as I have been doing so far? Or should I put some of them into the WEB-INF/lib
directory?
这里的最佳做法是什么?
What's the best practice here?
推荐答案
我一直在做与命令行相同的操作,但是通过配置 maven我的POM中的-install-plugin
(请阅读最后的说明):
I've been doing the same that you do with the command line, but by configuring maven-install-plugin
in my POM (please read the note at the end):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-vegetables</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.basedir}/lib/vegetables-1.0.jar</file>
<groupId>vegetables</groupId>
<artifactId>potatoes</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
<execution>
<id>install-minerals</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.basedir}/lib/minerals-1.0.jar</file>
<groupId>minerals</groupId>
<artifactId>rocks</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
效率低,因为文件反复安装,但它比手动制作要麻烦得多。无论如何,我认为你应该试一试。
It is much less efficient, because files get installed over and over, but it is much less annoying than making it manually. Anyway, I think you should give it a try.
这篇关于是否最好将项目jar文件Maven化或将它们放在WEB-INF / lib中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!