【问题标题】:What is the proper gradle setup for JPA Static Metamodel Generator?JPA 静态元模型生成器的正确 gradle 设置是什么?
【发布时间】:2016-07-12 22:56:56
【问题描述】:

我正在尝试使用 JPA 静态元模型生成器。我找到了a tutorial page,它解释了如何在 Gradle 中进行设置。我还发现a stackoverflow comment 说使用相同的类路径。它是:

classpath "gradle.plugin.at.comm_unity.gradle.plugins:jpamodelgen-plugin:1.1.1"

但是,当我尝试使用它时,我得到一个 gradle build 错误:

Error:Could not find gradle.plugin.at.comm_unity.gradle.plugins:jpamodelgen-plugin:1.1.1.
Searched in the following locations:
https://repo1.maven.org/maven2/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.pom
https://repo1.maven.org/maven2/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.jar
https://jcenter.bintray.com/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.pom
https://jcenter.bintray.com/gradle/plugin/at/comm_unity/gradle/plugins/jpamodelgen-plugin/1.1.1/jpamodelgen-plugin-1.1.1.jar

有什么问题?这个位置过时了吗?如果有,新的是什么?

【问题讨论】:

    标签: java hibernate jpa


    【解决方案1】:

    原来教程页面确实有答案,只是在示例中注释掉了。必须指定正确的 Maven 存储库。这对我有用:

    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    

    【讨论】:

      【解决方案2】:

      首先声明 gradle 插件库:

      buildscript {
         repositories {
            jcenter()
            maven {
               url "https://plugins.gradle.org/m2/"
            }
            //... other repositories
         }
      
         dependencies {
            classpath "at.comm_unity.gradle.plugins.jpamodelgen:plugin:1.1.2"
         }
      } 
      

      应用 gradle 插件:

      apply plugin: "com.github.iboyko.gradle.plugins.jpamodelgen"
      
      jpaModelgen {
          library = "org.hibernate:hibernate-jpamodelgen:4.3.8.Final"
          jpaModelgenSourcesDir = "src/src/java"
      }
      
      compileJava.options.compilerArgs += ["-proc:none"]
      

      配置的最后一行应该始终存在,否则它将删除您的原始源代码。

      【讨论】:

      • 未找到 ID 为 'com.github.iboyko.gradle.plugins.jpamodelgen' 的插件。
      • @PiotrDajlido 请参阅:readme
      猜你喜欢
      • 1970-01-01
      • 2015-07-22
      • 1970-01-01
      • 2013-09-06
      • 2019-10-01
      • 2014-12-23
      • 2014-06-23
      • 1970-01-01
      • 2019-01-06
      相关资源
      最近更新 更多