Grails 3.2.6 with spring security. In memory h2 database is not created when saving users -


i didn't find solution other postings although seems problems others have encountered.

this application.yml

--- grails:     profile: web-plugin     codegen:         defaultpackage: bioprofile     spring:         transactionmanagement:             proxies: false info:     app:         name: '@info.app.name@'         version: '@info.app.version@'         grailsversion: '@info.app.grailsversion@' spring:     main:         banner-mode: "off"     groovy:         template:             check-template-location: false  # spring actuator endpoints disabled default endpoints:     enabled: false     jmx:         enabled: true  --- grails:     mime:         disable:             accept:                 header:                     useragents:                         - gecko                         - webkit                         - presto                         - trident         types:             all: '*/*'             atom: application/atom+xml             css: text/css             csv: text/csv             form: application/x-www-form-urlencoded             html:               - text/html               - application/xhtml+xml             js: text/javascript             json:               - application/json               - text/json             multipartform: multipart/form-data             pdf: application/pdf             rss: application/rss+xml             text: text/plain             hal:               - application/hal+json               - application/hal+xml             xml:               - text/xml               - application/xml     urlmapping:         cache:             maxsize: 1000     controllers:         defaultscope: singleton     converters:         encoding: utf-8     views:         default:             codec: html         gsp:             encoding: utf-8             htmlcodec: xml             codecs:                 expression: html                 scriptlets: html                 taglib: none                 staticparts: none endpoints:     jmx:         unique-names: true  --- hibernate:     cache:         queries: false         use_second_level_cache: true         use_query_cache: false         region.factory_class: org.hibernate.cache.ehcache.singletonehcacheregionfactory  datasources:     datasource:         pooled: true         jmxexport: true         driverclassname: org.h2.driver         username: sa         password:         dbcreate: create-drop         dialect : com.hp.opr.hibernate.dialect.h2dialect         url: jdbc:h2:mem:blogdb;mvcc=true;lock_timeout=10000;db_close_on_exit=false      master:         pooled: true         jmxexport: true         driverclassname: org.h2.driver         username: sa         password:         dbcreate: create-drop         url: jdbc:h2:mem:masterdb;mvcc=true;lock_timeout=10000;db_close_on_exit=false 

but when application starts , in bootstrap try add users:

    user admin = new user(username: 'admin', password: 'password')     admin.save(flush: true)     user user = new user(username: 'user', password: 'user')     user.save(flsuh:true)      role adminrole = new role(authority: role.role_admin)     adminrole.save(flush:true)      role userrole = new role(authority: role.role_user)     userrole.save(flush:true)      userrole.create(admin, adminrole)     userrole.create(admin, userrole)     userrole.create(user, userrole) 

no database created. if open console url: http://localhost:8080/dbconsole database created. idea why ?

you using in-memory configuration of h2 in grails config, no database file created. when open dbconsole, there problably connection string file instead of in-memory configuration, db file created. change config in dbconsole configuration.


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -