简体   繁体   English

如何强制Hibernate 3.3或3.5使用CGLib而不是Javassist?

[英]How to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist?

Is it still possible to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist? 是否仍然可以强制使用Hibernate 3.3或3.5来使用CGLib而不是Javassist? In my properties file, I set 在我的属性文件中,我设置了

hibernate.bytecode.provider = cglib

But this doesn't seem to do it. 但这似乎并没有这样做。 Any thoughts? 有什么想法吗?

It seems some people didn't read my answer correctly so I'll rephrase: your hibernate.properties looks correct, the property is well defined, it should work. 似乎有些人没有正确阅读我的答案所以我会改写:你的hibernate.properties看起来正确,属性定义良好,它应该工作。 So, sorry for the question but is CGlib on the classpath? 所以,对不起这个问题,但CGlib在类路径上?

Update: Just tested and it works for me. 更新:刚刚测试过,它对我有用。 Here is the output I get at initialization time: 这是我在初始化时获得的输出:

15 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
18 [main] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false, hibernate.bytecode.provider=cglib}
20 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib

PS: Note that CGLIB support has been deprecated recently (this doesn't mean you won't be able to use CGLIB but the integration it not maintained anymore). PS:请注意, CGLIB支持最近已被弃用 (这并不意味着您将无法使用CGLIB,而是不再维护它的集成)。

Yeah, also put 是的,也放了

hibernate.properties 

into some source folder and remember to have the hibermate-cglib-repack in dependencies: 进入一些源文件夹并记得在依赖项中使用hibermate-cglib-repack:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-cglib-repack</artifactId>
    <version>2.1_3</version>
</dependency> 

Remember that CGLIB library is not developed for about 4 years. 请记住,CGLIB库大约4年没有开发。 You should do everything however to make your code working with Javassist, which is still actively maintained. 但是,您应该尽一切努力使您的代码与Javassist一起使用,而Javassist仍在积极维护。

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

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