如何在Intellij IDEA运行之前启用Hibernate构建时字节码增强功能? [英] How to enable Hibernate build-time bytecode enhancement before Intellij IDEA run?
问题描述
apply plugin:'enhance'
buildscript {
存储库{
mavenCentral()
}
依赖项{
classpath'org.hibernate:hibernate-gradle-plugin:VERSION'
}
}
依赖关系{
编译组:'org.hibernate.javax.persistence',名称:'hibernate-jpa- [SPEC -VERSION] -api',版本:'[IMPL-VERSION]'
编译组:'org.hibernate',名称:'hibernate-gradle-plugin',版本:'VERSION'
}
如果不是通过Gradle运行项目,我想直接通过Intellij运行我的主类(shift-F10)。在应用程序运行之前是否也可以执行构建时字节码增强?我应该如何实现这一目标?
Hibernate在运行时会执行字节码检测,所以你不必做任何特殊的事情。 / p>
实际上,它不是字节码检测,这意味着要改变现有的类,而是代理,这意味着,现有的类由动态生成的类使用。 >
In gradle you can achieve it using:
apply plugin: 'enhance'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.hibernate:hibernate-gradle-plugin:VERSION'
}
}
dependencies {
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-[SPEC-VERSION]-api', version: '[IMPL-VERSION]'
compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: 'VERSION'
}
What if instead of running the project through Gradle, I want to run my main class directly through Intellij (shift-F10). Is it possible to also perform build-time bytecode enhancement before the application run? How should I achieve this?
Hibernate does "bytecode instrumentation" at runtime, so you don't have to do anything special for it to happen.
Actually it is not bytecode instrumentation, which means changing existing classes, but proxying, which means, the existing classes are used by classes that get generated on the fly.
这篇关于如何在Intellij IDEA运行之前启用Hibernate构建时字节码增强功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!