【问题标题】:Grails - Database Reverse Engineer plugin not foundGrails - 找不到数据库逆向工程师插件
【发布时间】:2016-01-21 23:41:30
【问题描述】:

环境

Grails 2.4.4
PostgreSQL 9.4
JDK 1.7

我一直在努力让这个插件工作。 (我还是个 grails 新手,更不用说编程了。)

我尝试尽我所能找到,但仍然收到这个不合时宜的错误消息。

Loading Grails 2.4.4
|Configuring classpath
|Running pre-compiled script
|Script 'DbReverseEngineer' not found, did you mean:
   1) SetVersion
   2) GenerateRestfulController
   3) GenerateViews
   4) GenerateController
   5) DbmGenerateChangelog
Please make a selection or enter Q to quit: 

这是我在我的配置文件中没有的权利。 (我尝试了很多更改,例如 Hibernate、插件版本等,但总是以该消息结束。)

grails.project.dependency.resolver = "maven" 
grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility

    repositories {
        inherits true // Whether to inherit repository definitions from plugins

        grailsPlugins()
        grailsHome()
        mavenLocal()
        grailsCentral()
        mavenCentral()
        // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
        mavenRepo "http://repository.codehaus.org"
        //mavenRepo "http://download.java.net/maven/2/"
        mavenRepo "http://repo.grails.org/grails/repo/"
        mavenRepo "http://repository.jboss.com/maven2/"
    }

    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
        // runtime 'mysql:mysql-connector-java:5.1.29'
        test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
        runtime "org.postgresql:postgresql:9.4-1205-jdbc41"
        compile "org.grails.plugins:db-reverse-engineer:4.0.0"

   }

    plugins {
        // plugins for the build system only
        build ":tomcat:7.0.55"

        // plugins for the compile step
        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.8'
        compile ":asset-pipeline:1.9.9"
        compile ":postgresql-extensions:4.6.1"
        compile ":jquery:1.11.1"
        compile ":joda-time:1.5"
        compile "org.grails.plugins:db-reverse-engineer:4.0.0"

        // plugins needed at runtime but not for compilation
        runtime ":hibernate4:4.3.6.1"// or ":hibernate:3.6.10.18" 
        runtime ":database-migration:1.4.0"
        runtime ":jquery:1.11.1"
        runtime ":db-reverse-engineer:4.0.0"
  }

提前致谢。

编辑 1 所以,我像这样更改了Script folder下的DbReverseEngineer.groovy。

mergedConfig.driverClassName = dsConfig.driverClassName ?: 'org.postgresql.Driver'
mergedConfig.password = dsConfig.password ?: ''
mergedConfig.username = dsConfig.username ?: 'postgres'
mergedConfig.url = dsConfig.url ?: 'jdbc:postgresql://localhost:5432/myApp'

我根据 Burt 和 Emmanuel 的建议更改了 plugindependency。当我运行grails db-reverse-engineer 命令时,我得到了这个错误。

Compilation error: startup failed:
Compile error during compilation with javac.
/home/Documents/Grails_Workspace/myApp/target/work/plugins/cache-1.1.8/src/java/grails/plugin/cache/web/GenericResponseWrapper.java:203: error: method does not override or implement a method from a supertype
    @Override
    ^
/home/Documents/Grails_Workspace/myApp/target/work/plugins/cache-1.1.8/src/java/grails/plugin/cache/web/filter/PageFragmentCachingFilter.java:389: error: cannot find symbol
            contentType = response.getContentType();
                                  ^
  symbol:   method getContentType()
  location: variable response of type HttpServletResponse
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

这些错误是什么意思,我该如何摆脱它? 谢谢。

【问题讨论】:

  • 嗨,蒙蒂,你设法让它工作了吗?我也尝试过 Rev Gen 一些表格,并在您的原始问题中更新 [Edit 1] 中的确切错误。帮忙?

标签: grails grails-plugin


【解决方案1】:

你已经设置了两次相同的插件:

  1. compile 'org.grails.plugins:db-reverse-engineer:4.0.0'
  2. runtime ':db-reverse-engineer:4.0.0'

根据插件的页面应该配置为编译时依赖:

compile "org.grails.plugins:db-reverse-engineer:4.0.0"

插件确实有声称缺少的命令。你可以看到它here。所以你可能需要通过运行来刷新依赖:

grails refresh-dependencies

【讨论】:

  • 对于 Grails 2,它应该是 plugins 块中的 compile ":db-reverse-engineer:4.0.0"。您还应该删除 dependencies 块中的依赖项,因为这是针对 jar 文件依赖项的,这是一个插件。还要删除 mavenRepo "http://repository.codehaus.org",因为 codehaus 关闭并且他们的服务器都没有运行
  • @Emmanuel Rosa,谢谢。我昨天把它缩小了,错误也少了。我遇到了一些错误并编辑了我的 DbReverseEngineer.groovy。
  • @Burt Beckwith,感谢您的评论。我继续修复它。我有一些新问题。你能看看我做得对吗?我会尽快编辑我的问题。 (哦,我旁边就有你的书。它帮助我完成了上一个项目。谢谢。)
猜你喜欢
  • 1970-01-01
  • 2023-03-24
  • 2011-07-24
  • 2011-12-21
  • 2012-06-24
  • 2016-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多