Hibernate Gradle插件等效于hibernate-enhance-maven-plugin
,并提供了构建时代码增强功能。 official docs不提及apply plugin: 'something'
行。如果我按照向导的指示去做,我会得到:
Could not find method hibernate() for arguments...
我尝试用
apply plugin: 'enhance'
(如this thread建议)和apply plugin: 'org.hibernate.orm'
(如this test建议)猜测插件名称,但这只是说具有该ID的插件是未知的。是否有人成功设置了此插件?
我的build.gradle如下:
allprojects {
group 'xxx'
version '1.0-SNAPSHOT'
}
subprojects {
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
...
}
}
project(':xxx-model') {
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.hibernate:hibernate-gradle-plugin:5.0.7.Final"
}
}
apply plugin: 'org.hibernate.orm'
hibernate {
enhance {}
}
}
... more unrelated project blocks here
尝试将
buildscript{...}
移到根,allprojects
和subprojects
中,但没有得到有用的结果。
最佳答案
apply plugin: 'org.hibernate.orm'
插件代码表明您从测试中得到的是正确的。您可能会缺少的是
repositories
部分中的buildScript
部分,以从中获取插件jar。
关于hibernate - 如何设置Hibernate Gradle插件来增强字节码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35552109/