2017-04-07 6 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) 

何のデータベースが作成されません。 しかし、私がURLからコンソールを開くと:http://localhost:8080/dbconsoleデータベースが作成されています。 理由は何ですか?

+0

検証エラーが多分? – injecteer

+0

これはセキュリティに関連していません –

答えて

1

grails configでH2のメモリ内設定を使用しているため、データベースファイルは作成されません。しかし、dbconsoleを開くと、in-memory構成の代わりにファイルを持つ接続文字列がある可能性があるので、dbファイルが作成されます。 dbconsole構成の設定を変更します。

関連する問題