简体   繁体   English

Spring,Jersey,CGLIB和Javassist

[英]Spring, Jersey, CGLIB and Javassist

I am migrating an old project from Ant to Gradle (yes, there is still an Ant-based project in 2014). 我正在将一个旧项目从Ant迁移到Gradle(是的,2014年仍然有一个基于Ant的项目)。 It has all sorts of nonsense thrown into its lib/ dir, and I'm very keen on dumping anything unnecessary as part of this migration. 它的lib/ dir中有各种各样的废话,我非常热衷于在此迁移过程中丢弃任何不必要的内容。

The project is based on Spring 3.0.5 and Jersey 1.8 . 该项目基于Spring 3.0.5Jersey 1.8 It is not using Hibernate but instead using Cassandra. 它不使用Hibernate,而是使用Cassandra。 The project seems to think it needs javassist 3.12.0 , but didn't pull cglib . 该项目似乎认为它需要javassist 3.12.0 ,但是没有拉cglib

I thought I had some vague recollection of perhaps one of these optionally using javassist, but it seems by recollection is lying to me. 我以为我对其中的一种可能选择使用javassist进行了模糊的回忆,但是似乎回忆起来对我来说是骗人的。 Is it safe to remove this dependency? 删除此依赖关系安全吗?

Depending on how you're using Spring you might need to add an explicit dependency on CGLIB. 根据您使用Spring的方式,您可能需要添加对CGLIB的显式依赖。 It's marked as an optional dependency in 3.0. 在3.0中将其标记为可选依赖项。 In Spring 3.2, the CGLIB classes were repackaged into the Spring JARs so an explicit dependency on CGLIB is no longer required . 在Spring 3.2中,将CGLIB类重新打包到Spring JAR中,因此不再需要对CGLIB的显式依赖 You would need CGLIB if you're proxy-target-class="true" or @Configuration . 如果您是proxy-target-class="true"@Configuration则需要CGLIB。

I just checked one of my projects that's similar to yours (Spring 3.0.x and Jersey 1.x). 我刚刚检查了一个与您的项目相似的项目(Spring 3.0.x和Jersey 1.x)。 I have dependency on Javassist but Maven tells me it's because of Hibernate. 我依赖Javassist,但Maven告诉我这是因为Hibernate。 I don't see an explicit dependency from Jersey 1.x to Javassist. 我看不到从Jersey 1.x到Javassist的明确依赖关系。

If I were you, I'd leave the Javassist dependency out of the POM and let Maven take care of pulling it in if it's necessary. 如果您是我,我将把Javassist依赖项放在POM之外,并让Maven在必要时负责将其引入。 I would only add an explicit dependency on Javassist if it was an optional dependency that I needed or if Maven made the wrong choice about which version to include. 如果我需要一个可选的依赖项,或者如果Maven对要包含的版本做出了错误的选择,则仅在Javassist上添加显式依赖项。

Is it safe to remove this dependency? 删除此依赖关系安全吗?

It's hard to say without seeing your entire pom.xml or the list of JARs that the Ant script worked with. 很难看到整个pom.xml或与Ant脚本一起使用的JAR列表。

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

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