Hibernate Gradle插件相当于hibernate-enhance-maven-plugin并提供了构建时代码增强功能.在官方的文档不提apply plugin: 'something'线.如果我按照指南说的那样做,我得到:
无法为参数找到方法hibernate()...
我试着猜测插件名称apply plugin: 'enhance'(正如这个线程建议的那样)和apply plugin: 'org.hibernate.orm'(正如这个测试建议的那样),但它只是说带有该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
Run Code Online (Sandbox Code Playgroud)
通过移动buildscript{...}进入根实验,allprojects并subprojects没有任何有用的结果.
Vla*_*cea 13
一个完整的示例如下所示:
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
}
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.hibernate:hibernate-gradle-plugin:5.1.0.Final"
}
}
apply plugin: 'org.hibernate.orm'
hibernate {
enhance {
enableLazyInitialization= true
enableDirtyTracking = true
enableAssociationManagement = true
}
}
dependencies {
compile 'org.hibernate:hibernate-core:5.1.0.Final'
}
Run Code Online (Sandbox Code Playgroud)
apply plugin: 'org.hibernate.orm'
Run Code Online (Sandbox Code Playgroud)
插件代码表明您从测试中得到的信息是正确的。您可能缺少的是repositories您的buildScript部分中的一个部分,用于从中获取插件 jar。
| 归档时间: |
|
| 查看次数: |
3446 次 |
| 最近记录: |