2017-04-07 44 views
0

我没有找到来自其他帖子的解决方案,但这似乎是其他人遇到的问题。Grails 3.2.6具有弹簧安全性。在内存中保存用户时不会创建h2数据库

这是我application.yml

--- 
grails: 
    profile: web-plugin 
    codegen: 
     defaultPackage: bioprofile 
    spring: 
     transactionManagement: 
      proxies: false 
info: 
    app: 
     name: '@[email protected]' 
     version: '@[email protected]' 
     grailsVersion: '@[email protected]' 
spring: 
    main: 
     banner-mode: "off" 
    groovy: 
     template: 
      check-template-location: false 

# Spring Actuator Endpoints are Disabled by 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 

但是当应用程序启动并在引导我尝试添加一些用户:创建

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) 

没有数据库。 但是,如果我从网址:http://localhost:8080/dbconsole打开控制台比创建数据库。 任何想法为什么?

+0

任何验证错误可能? – injecteer

+0

这与安全无关 –

回答

1

您在grails配置中使用H2的内存中配置,因此没有创建数据库文件。但是,当您打开dbconsole时,有可能是连接字符串与文件而不是内存配置,因此创建了一个db文件。更改dbconsole配置中的配置。

相关问题