2016-07-12 78 views
0

我試圖安裝mongeez插件,我收到以下錯誤, 我已經包括, 插件{ .. 編譯「:mongeez:0.2.3」 .. } in BuildConfig.groovy獲取錯誤安裝mongeez插件

創建名爲'grails.mongeez.MongeezController'的bean時出錯:bean初始化失敗;嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名爲'mongeez'的bean時出錯:無法在設置bean屬性'mongo'時解析對bean'mongo'的引用;嵌套的例外是org.springframework.beans.factory.NoSuchBeanDefinitionException:無豆命名爲 '蒙戈' 被定義 ..... ..... .... .... ..... .....

引起:org.springframework.beans.factory.BeanCreationException:創建名爲'mongeez'的bean時出錯:在設置bean屬性'mongo'時無法解析對bean'mongo'的引用;嵌套的例外是org.springframework.beans.factory.NoSuchBeanDefinitionException:無豆命名爲「蒙戈」被定義

回答

0
I'm able to install the plugin by adding mongeez as a dependency instead of a plugin. 

BuildConfig.groovy 

dependencies { 
...... 
..... 
compile 'org.mongeez:mongeez:0.9.6' 
..... 
...... 
} 

Contents of migrations folder(Change logs) 
I have grails-app/migrations/test.js 
     grails-app/migrations/mongeez.xml 

This is my mongeez.xml 

<changeFiles> 
    <file path="test.js"/> 
</changeFiles> 

This is my test.js 

db.movie.insert({ 
    "name":"tutorials point" 
}); 


I have written a groovy script as follows, 


import com.mongodb.Mongo 
import org.springframework.core.io.ClassPathResource 
import org.mongeez.Mongeez 

includeTargets << grailsScript("_GrailsInit") 

target(updateMongo: "Update the mongo DB!") { 
    println "The script is about to run" 

    def host = 'localhost' 
    def port = 27017 
    def databaseName = 'reporting' 

    Mongeez mongeez = new Mongeez() 
    mongeez.setFile(new ClassPathResource("/migrations/mongeez.xml")) 
    mongeez.setMongo(new Mongo(host, port)) 
    mongeez.setDbName(databaseName) 
    mongeez.process() 

    println "The script just ran" 
} 
setDefaultTarget(updateMongo) 




When I run the above script both the print statements are getting executed. 
A mongeez collection also got created in my reporting db but the contents of test.js(movie collection) is not reflected in my mongodb , i.e movie collection is not getting created. 

Please suggest me if I'm missing something. 
+0

在哪裏,我需要把我的變更和mongeez文件?我有他們,grails-app/migrations文件夾 – Sharath

0
Got mongeez plugin working by replacing ClassPathResource with FileSystemResource. 

Mongeez mongeez = new Mongeez() 
mongeez.setFile(new FileSystemResource(path)) // Give the path to your mongeez.xml 
mongeez.setMongo(new Mongo(properties.host, properties.port)) 
mongeez.setDbName(databaseName) 
mongeez.process()