mysql - Using mongodb and hibernate with grails3 -
i need run grails 3 app against mysql/hibernate , mongodb. (had running on grails 2.5 without hitch).
i tried many different combinations, searched , tried related answers, no luck.
used latest mongodb plugin doc configuration.
using grails 3.1.10:
grailsversion=3.1.10
i started following details in build.gradle:
buildscript { ext { grailsversion = project.grailsversion } repositories { mavenlocal() maven { url "https://repo.grails.org/grails/core" } } dependencies { classpath "org.grails:grails-gradle-plugin:$grailsversion" classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2" classpath "org.grails.plugins:hibernate4:5.0.10" } } ... 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-dependencies" compile "org.grails:grails-web-boot" compile "org.grails.plugins:cache" compile "org.grails.plugins:scaffolding" compile "org.grails.plugins:hibernate4" compile "org.hibernate:hibernate-ehcache" console "org.grails:grails-console" profile "org.grails.profiles:web" runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2" testcompile "org.grails:grails-plugin-testing" testcompile "org.grails.plugins:geb" testruntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" testruntime "net.sourceforge.htmlunit:htmlunit:2.18" //databases compile 'org.grails.plugins:mongodb:6.0.0.m2' runtime 'mysql:mysql-connector-java:5.1.36' ... }
the application.yml:
--- hibernate: cache: queries: false use_second_level_cache: true use_query_cache: false region.factory_class: org.hibernate.cache.ehcache.singletonehcacheregionfactory datasource: pooled: true jmxexport: true driverclassname: com.mysql.jdbc.driver environments: development: datasource: dbcreate: update url: jdbc:mysql://localhost:3306/dbname driverclassname: com.mysql.jdbc.driver dialect: org.hibernate.dialect.mysql5innodbdialect username : "xxx" password : "yyy" properties: maxactive : 50 maxidle: 25 minidle: 5 ... grails: mongodb: host: "localhost" port: 27017 username: "blah" password: "blah" databasename: "foo"
now gives me error:
15:13:58.001 [quiet] [system.out] error org.springframework.boot.springapplication - application startup failed 15:13:58.001 [quiet] [system.out] java.lang.noclassdeffounderror: org/grails/datastore/gorm/plugin/support/configsupport 15:13:58.001 [quiet] [system.out] @ grails.plugins.mongodb.mongodbgrailsplugin.dowithspring(mongodbgrailsplugin.groovy:42)
the mongodb grails plugin not find configsupport
configsupport.prepareconfig(config, (configurableapplicationcontext) applicationcontext)
i tried add following plugins in orders possible:
//compile 'org.grails:grails-datastore-gorm-hibernate4:6.0.0.m2' //compile 'org.grails:grails-datastore-core:4.0.0.m2' //compile 'org.grails:grails-datastore-gorm-plugin-support:6.0.0.m2' //compile 'org.springframework.data:spring-data-mongodb:1.9.2.release' //compile 'org.mongodb:mongodb-driver:3.3.0' //compile 'org.mongodb:mongo-java-driver:3.3.0'
no luck.
i moved mongodb: section down grails: section in yml file. same error.
so question how mongodb running mysql grails3.
ok, stupid me. solved puzzle using these simple dependency settings:
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-dependencies" compile "org.grails:grails-web-boot" compile "org.grails.plugins:cache" compile "org.grails.plugins:scaffolding" compile "org.grails.plugins:hibernate4" compile "org.hibernate:hibernate-ehcache" console "org.grails:grails-console" profile "org.grails.profiles:web" runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2" testcompile "org.grails:grails-plugin-testing" testcompile "org.grails.plugins:geb" testruntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" testruntime "net.sourceforge.htmlunit:htmlunit:2.18" //databases compile 'org.grails.plugins:mongodb' runtime 'mysql:mysql-connector-java:5.1.36' runtime 'com.googlecode.json-simple:json-simple:1.1'
it seems following line made difference:
compile 'org.grails.plugins:mongodb'
omitting version number. should explained in docs bit better. thing defining versions, or old fashioned these days? :-)
happy have working
Comments
Post a Comment