Gradle 无法解析最近创建的grails项目中的依赖项

Gradle 无法解析最近创建的grails项目中的依赖项,gradle,grails,groovy,Gradle,Grails,Groovy,当我尝试构建我的项目时,这是gradle的痕迹: :compileIntegrationTestJava NO-SOURCE startup failed: /src/integration-test/groovy/shit/UserFunctionalSpec.groovy: 11: unable to resolve class GebSpec @Integration /src/integration-test/groovy/shit/UserServiceSpec.groovy:

当我尝试构建我的项目时,这是gradle的痕迹:

:compileIntegrationTestJava NO-SOURCE
startup failed:
/src/integration-test/groovy/shit/UserFunctionalSpec.groovy: 11: 
unable to resolve class GebSpec 
@Integration

/src/integration-test/groovy/shit/UserServiceSpec.groovy: 6: unable to resolve class org.hibernate.SessionFactory
   import org.hibernate.SessionFactory
我不明白为什么会出现此错误,该项目是使用grails cli创建的:

grails创建应用程序grails rest--profile=RESTAPI--features=mongodb

并生成一个简单的域用户类,然后使用grails cli生成所有

这是我的身材。格雷德尔:

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:views-gradle:1.1.6"
    }
}

version "0.1"
group "shit"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.plugins.views-json"

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-codecs"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-datasource"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:mongodb"
    compile "org.grails.plugins:views-json"
    compile "org.grails.plugins:views-json-templates"
    console "org.grails:grails-console"
    profile "org.grails.profiles:rest-api"
    provided "org.grails.plugins:embedded-mongodb:1.0.2"
    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails:grails-datastore-rest-client"
    testCompile "org.grails:grails-web-testing-support"
}

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always')
    addResources = true
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
我已尝试在调试模式下解决依赖关系,但看不到更准确的错误消息。
如果这是一个新的、干净的项目,为什么我的gradle会有这样的问题?

grails创建应用程序grails rest--profile=rest api--features=mongodb

不生成名为
/src/integration test/groovy/shit/UserFunctionalSpec.groovy的文件

该测试显然是一个Hibernate Geb测试,您没有这些依赖项

编辑:


RESTAPI配置文件与generate all命令及其提供的依赖项不一致。要继续工作,只需删除生成的
UserFunctionalSpec
UserServiceSpec
。请提交一个问题

,那么问题是您希望grails的一个依赖项能够过渡地为您引入Hibernate?你说你已经在调试模式下检查了依赖项-你在Hibernate上看到了一个可传递的依赖项吗?如果有文件证明grails createapp和MongoDB确实为你自动设置了Hibernate(我不知道Hibernate支持MongoDB),那么我想这是grails createapp中的一个bug。嗨,兄弟,谢谢你的回答。Hibernate支持MongoDB。您知道如何修复它吗?下面是其他人在GitHub上为hibernate和mongodb编写的build.gradle:您可以尝试从那里复制hibernate和hibernate ogm编译依赖项。他在文件顶部定义了要用$s替换的版本号,因此现在手动将其替换到依赖项行可能更简单。但是我不知道Hibernate和MongoDB,所以不知道这是否是你想要的!我试着把它放在依赖项上,但也有同样的错误。我用这个不同的依赖项再次执行了相同的项目,但它不起作用,无论如何感谢您。是的,很抱歉我忘记了编写,而不是生成一个域用户类,然后使用grails cli生成所有。感谢您的回答,我创建了这个问题()