简体   繁体   English

如何在 Intellij IDEA 运行之前启用 Hibernate 字节码检测?

[英]How to enable Hibernate bytecode instrumentation just before Intellij IDEA run?

In gradle you can achieve it using:在 gradle 中,您可以使用以下方法实现:

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).如果不是通过 Gradle 运行项目,我想直接通过 Intellij (shift-F10) 运行我的主类怎么办。 Is it possible to also perform build-time bytecode instrumentation just 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. Hibernate 在运行时执行“字节码检测”,因此您无需执行任何特殊操作即可实现。

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.实际上,它不是字节码检测,这意味着更改现有类,而是代理,这意味着现有类被动态生成的类使用。

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

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