【问题标题】:How to mavenize Grails 2 Application with build-test-data plugin如何使用 build-test-data 插件对 Grails 2 应用程序进行 mavenize
【发布时间】:2012-09-16 00:17:09
【问题描述】:

我正在尝试对使用 build-test-data-2.0.3 的 grails 2.1 应用程序进行 mavenize,由于某种原因它无法导入 grails.test.mixin.support.*。

我认为这与范围有关,所以我尝试了不同的范围,但没有帮助。

我的假设是 grails.test.mixin.support 并且其他要求已经与 grails 核心一起下载,我是否需要为此插件添加任何特定的依赖项?

谢谢

我得到的错误是:

 package grails.test.mixin.support does not exist

这是创建问题需要做的事情:

1- 创建应用程序 delme

2- 添加构建测试插件

3- 创建 pom com.company

4- mvn 安装

这是我在 pom 中的依赖:

 <dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>build-test-data</artifactId>
    <version>2.0.3</version>
    <scope>compile</scope>
    <type>zip</type>
</dependency> 

构建配置:

plugins {
    runtime ":hibernate:$grailsVersion"
    runtime ":jquery:1.7.2"
    runtime ":resources:1.1.6"

    // Uncomment these (or add new ones) to enable additional resources capabilities
    //runtime ":zipped-resources:1.0"
    //runtime ":cached-resources:1.0"
    //runtime ":yui-minify-resources:0.1.4"

    build ":tomcat:$grailsVersion"

    runtime ":database-migration:1.1"

    compile ':cache:1.0.0'
}

【问题讨论】:

  • 您的 BuildConfig.groovy 看起来如何?我有相同的设置,但我没有看到问题。
  • 我没有更改Buidlconfig,因为我使用maven下载依赖项。
  • @allthenutsandbolts 你也在用maven吗?
  • 是的,我也在使用 maven。我没有看到错误
  • 如果您希望 Grails 从您的 pom 文件中获取依赖项,您需要将 pom true 添加到您的 grails.project.dependency.resolution 闭包中。

标签: grails grails-plugin


【解决方案1】:

如果有人遇到 maven 无法编译某些类的类似问题,这可能会对他们有所帮助。

在我的例子中,maven 抱怨的是 build-test-data 插件使用的一些类。问题是 Maven 不知道 build-test-data 在这种情况下使用的那些类是 grails.test.mixin.support.MixinMethod。这是 grails-plugin-testing 包的一部分。

Maven 需要知道这一点,以便它可以将它放在类路径中(我假设),如果它找不到它,将无法编译它。我需要做的只是将该依赖项添加到 maven,因此 maven 可以将其放入类路径中。

感谢this jpearlin 的回复帮助我解决了这个问题。

我添加了此依赖项,问题已解决。

        <dependency>
              <groupId>org.grails</groupId>
              <artifactId>grails-plugin-testing</artifactId>
              <version>${grails.version}</version>
              <scope>test</scope>
        </dependency>

【讨论】:

    猜你喜欢
    • 2013-04-12
    • 1970-01-01
    • 1970-01-01
    • 2018-03-04
    • 1970-01-01
    • 2014-06-01
    • 1970-01-01
    • 2012-10-01
    • 2019-06-08
    相关资源
    最近更新 更多