如何在我的项目中引用JAR库作为外部?

时间:2023-01-13 11:46:11

I'm working in a Web Project on Java using Eclipse.

我正在使用Eclipse在Java上进行Web项目。

This project will be deployed, at least, as "Develop" and "Testing" in two different WARs.

该项目至少将作为“开发”和“测试”部署在两个不同的WAR中。

The project is working fine.

该项目工作正常。

But when I Exported as a WAR file, each WAR have inside a copy of the libraries used (Spring JARs, Quartz JARs, Hibernate JARs, etc).

但是当我导出为WAR文件时,每个WAR都包含所使用的库的副本(Spring JAR,Quartz JAR,Hibernate JAR等)。

So I'm repeating the JARs on each implementation.

所以我在每个实现上重复JAR。

So the Idea of my Boss is remove the JARs from the web project and:

因此,我的老板的想法是从Web项目中删除JAR并:

Option 1: Copy all the libraries to a windows folder and then reference with a "Relative Path".

选项1:将所有库复制到Windows文件夹,然后使用“相对路径”进行引用。

Option 2: Put the JARs on Java JRE/JDK lib folder and the reference the JARs in some way.

选项2:将JAR放在Java JRE / JDK lib文件夹中,并以某种方式引用JAR。

Also with this change, we are trying to solve a PermGem Exception

此外,通过此更改,我们正在尝试解决PermGem异常

What it is the best Idea?

什么是最好的想法?

I'm new with Java project, so I don't know how to do that.

我是Java项目的新手,所以我不知道该怎么做。

Thanks for yours answers and sorry for my poor english

谢谢你的回答,对不起我的英语不好

2 个解决方案

#1


0  

IMO the best idea is to bundle them with your application.

IMO最好的想法是将它们与您的应用程序捆绑在一起。

If for no other reason, this allows you to upgrade a library in one version without affecting the others.

如果没有其他原因,这允许您在一个版本中升级库而不影响其他版本。

#2


0  

I feel your current approach is better, having jars packed with each war. As @Dave said, if you put them to a common place it will have dependency problems. Also both of your options will not solve PermGen error, to solve that as a temporary measure try to increase PermGen memory using -XX:MaxPermSize JVM argument, even after this if you still get the out of memory error then you need to dig out where the memory leak is.

我觉得你现在的做法比较好,每场战争都装满了罐子。正如@Dave所说,如果你将它们放到一个共同的地方,它将会产生依赖性问题。另外你的两个选项都不会解决PermGen错误,解决这个问题作为一个临时措施尝试使用-XX:MaxPermSize JVM参数来增加PermGen内存,即使在此之后如果仍然出现内存不足错误那么你需要挖出去哪里内存泄漏是。

#1


0  

IMO the best idea is to bundle them with your application.

IMO最好的想法是将它们与您的应用程序捆绑在一起。

If for no other reason, this allows you to upgrade a library in one version without affecting the others.

如果没有其他原因,这允许您在一个版本中升级库而不影响其他版本。

#2


0  

I feel your current approach is better, having jars packed with each war. As @Dave said, if you put them to a common place it will have dependency problems. Also both of your options will not solve PermGen error, to solve that as a temporary measure try to increase PermGen memory using -XX:MaxPermSize JVM argument, even after this if you still get the out of memory error then you need to dig out where the memory leak is.

我觉得你现在的做法比较好,每场战争都装满了罐子。正如@Dave所说,如果你将它们放到一个共同的地方,它将会产生依赖性问题。另外你的两个选项都不会解决PermGen错误,解决这个问题作为一个临时措施尝试使用-XX:MaxPermSize JVM参数来增加PermGen内存,即使在此之后如果仍然出现内存不足错误那么你需要挖出去哪里内存泄漏是。