Grails - 找不到数据库反向工程插件

时间:2016-01-20 17:25:58

标签: grails grails-plugin

环境

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.

这些错误是什么意思,我怎么能摆脱它? 感谢。

1 个答案:

答案 0 :(得分:1)

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

  1. compile 'org.grails.plugins:db-reverse-engineer:4.0.0'
  2. runtime ':db-reverse-engineer:4.0.0'
  3. 根据插件的页面,它应该配置为编译时依赖:

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

    该插件确实拥有声称缺失的命令。你可以看到它here。因此,您可能需要运行以下命令来刷新依赖项:

    grails refresh-dependencies