java - Hibernate 5.3.7 的字节码增强
问题描述
我曾经在 Hibernate 4.x 中使用 ant 目标来检测我的类:
<target name="instrument" depends="compile">
<taskdef name="enhance" classname="org.hibernate.tool.enhance.EnhancementTask">
<classpath refid="extended.classpath"/>
<classpath path="${classbin.dir}"/>
</taskdef>
<instrument verbose="true">
<fileset dir="${TARGETROOT}/home/WEB-INF/classes">
<include name="org/zfin/publication/Publication.class"/>
</fileset>
</instrument>
</target>
但是当我升级到 Hibernate 5.3.7 时,这停止了工作。在蚂蚁中执行此操作的正确方法是什么?注意,我不使用 Maven。
我试过这个改变
<target name="instrument" depends="compile">
<taskdef name="enhance" classname="org.hibernate.tool.enhance.EnhancementTask">
<classpath refid="extended.classpath"/>
<classpath path="${classbin.dir}"/>
</taskdef>
<enhance base="${classbin.dir}" dir="${classbin.dir}/org/zfin/publication" failOnError="false" enableLazyInitialization="true"
enableDirtyTracking="false"
enableAssociationManagement="false"
enableExtendedEnhancement="false">
</enhance>
</target>
但它输出 [enhance] Unable to enhance class: Publication.class
表示它不工作。它增强了该目录中的一些类,但不是我需要的。
解决方案
我发现 Hibernate 5.3.7 正在使用 byte-buddy 1.8.17。升级到 byte buddy 1.10.18 时,一切正常!
推荐阅读
- parse-platform - 解析服务器 cosmosdb 不返回 GeoPoint 的结果
- php - Laravel 护照 oauth 路线总是返回 401 未经授权
- excel - 从范围对象中选择单元格
- c# - Windows 服务中的重叠任务
- javascript - 通过 cookie 检查用户是否已经看到了 div
- javascript - 设置间隔时如何在jquery中停止或结束函数
- sql - 如何根据年份获取 SQL 结果?
- php - CodeIgniter 中的 Cron 作业不起作用
- react-router - 如何保护核心ui中的路由反应
- docker - F# 类型提供可以与容器化 (Docker) 资源一起使用吗?