grails - Grails 3数据库迁移

标签 grails grails-plugin

刚刚从grails 2.3.11升级到3.2.0.M2
dbm-gorm-diff和其他dbm- *脚本有问题
我的应用程序具有多项目结构。域类放置在单独的插件中。

Build.gradle

buildscript {
repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
    classpath "org.grails:grails-gradle-plugin:$grailsVersion"
    classpath "org.grails.plugins:hibernate5:6.0.0.M2"
    classpath "org.grails.plugins:database-migration:2.0.0.RC4"
}

}
version "0.1"
group "core"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.grails-plugin-publish"


configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.grails:grails-dependencies"
    compile "org.grails.plugins:hibernate5"
    compile "org.grails.plugins:cache"
    compile "org.hibernate:hibernate-core:5.1.0.Final"
    compile "org.hibernate:hibernate-ehcache:5.1.0.Final"
    console "org.grails:grails-console"
    profile "org.grails.profiles:plugin:3.2.0.M2"
    provided "org.grails:grails-plugin-services"
    provided "org.grails:grails-plugin-domain-class"
    provided 'javax.servlet:javax.servlet-api:3.1.0'
    runtime "org.grails.plugins:database-migration:2.0.0.RC4"
    runtime "mysql:mysql-connector-java:5.1.39"

    testCompile "org.grails:grails-plugin-testing"
}

grailsPublish {
    // TODO: Provide values here
    user = 'user'
    key = 'key'
    githubSlug = 'app/core'
    license {
        name = 'Apache-2.0'
    }
    title = "Core"
    desc = "***"
    developers = ["***"]
    portalUser = ""
    portalPassword = ""    
}

sourceSets {
    main {
        resources {
            srcDir "grails-app/migrations"
        }
    }
}

application.yml
grails:
  profile: plugin
  codegen:
    defaultPackage: core
  spring:
    transactionManagement:
      proxies: false
info:
  app:
    name: '@info.app.name@'
    version: '@info.app.version@'
    grailsVersion: '@info.app.grailsVersion@'
spring:
  groovy:
    template:
      check-template-location: false
---
grails:
  plugin:
    databasemigration:
      updateOnStart: true
      updateOnStartFileNames:
        - changelog.groovy
        - changelog-part-2.groovy
hibernate:
  cache:
    queries: false
    use_second_level_cache: true
    use_query_cache: false
    region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'

dataSource:
  dbCreate: none
  driverClassName: "com.mysql.jdbc.Driver"
  dialect: "org.hibernate.dialect.MySQL5InnoDBDialect"
  url: "jdbc:mysql://localhost:3306/project?zeroDateTimeBehavior=convertToNull&autoreconnect=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8"
  username: "root"
  password: "root"
  properties:
    jmxEnabled: true
    initialSize: 5
    maxActive: 50
    minIdle: 5
    maxIdle: 25
    maxWait: 10000
    maxAge: 600000
    timeBetweenEvictionRunsMillis: 5000
    minEvictableIdleTimeMillis: 60000
    validationQuery: SELECT 1
    validationQueryTimeout: 3
    validationInterval: 15000
    testOnBorrow: true
    testWhileIdle: true
    testOnReturn: false
    jdbcInterceptors: ConnectionState
    defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

堆栈跟踪
2016-08-16 18:57:06.731  WARN 5736 --- [           main] o.s.mock.web.MockServletContext          : Couldn't determine real path of resource class path resource [src/main/webapp/WEB-INF/sitemesh.xml]

java.io.FileNotFoundException: class path resource [src/main/webapp/WEB-INF/sitemesh.xml] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:48) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.mock.web.MockServletContext.getRealPath(MockServletContext.java:458) ~[spring-test-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.grails.web.sitemesh.Grails5535Factory.<init>(Grails5535Factory.java:78) [grails-web-sitemesh-3.2.0.M2.jar:3.2.0.M2]
    at org.grails.web.servlet.view.SitemeshLayoutViewResolver.loadSitemeshConfig(SitemeshLayoutViewResolver.java:105) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
    at org.grails.web.servlet.view.SitemeshLayoutViewResolver.init(SitemeshLayoutViewResolver.java:67) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
    at org.grails.web.servlet.view.SitemeshLayoutViewResolver.onApplicationEvent(SitemeshLayoutViewResolver.java:146) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
    at org.grails.web.servlet.view.SitemeshLayoutViewResolver.onApplicationEvent(SitemeshLayoutViewResolver.java:42) [grails-web-gsp-3.2.0.M2.jar:3.2.0.M2]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:877) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at grails.boot.GrailsApp.run(GrailsApp.groovy:55) [grails-core-3.2.0.M2.jar:3.2.0.M2]
    at grails.ui.command.GrailsApplicationContextCommandRunner.run(GrailsApplicationContextCommandRunner.groovy:55) [grails-console-3.2.0.M2.jar:3.2.0.M2]
    at grails.ui.command.GrailsApplicationContextCommandRunner.main(GrailsApplicationContextCommandRunner.groovy:102) [grails-console-3.2.0.M2.jar:3.2.0.M2]
    2016-08-16 18:57:07.035  INFO 5736 --- [           main] .c.GrailsApplicationContextCommandRunner : Started GrailsApplicationContextCommandRunner in 21.719 seconds (JVM running for 23.484)
2016-08-16 18:57:07.035  INFO 5736 --- [           main] grails.boot.GrailsApp                    : Application starting in environment: development
Command execution error: Bean named 'sessionFactory' must be of type [org.springframework.beans.factory.FactoryBean], but was actually of type [org.hibernate.internal.SessionFactoryImpl]
2016-08-16 18:57:07.185  INFO 5736 --- [       Thread-7] g.u.s.DevelopmentWebApplicationContext   : Closing grails.ui.support.DevelopmentWebApplicationContext@2abc224d: startup date [Tue Aug 16 18:56:48 MSK 2016]; root of context hierarchy
2016-08-16 18:57:07.382  INFO 5736 --- [       Thread-7] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase -2147483648
2016-08-16 18:57:07.406  INFO 5736 --- [       Thread-7] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

你能帮助我吗?

最佳答案

关于grails - Grails 3数据库迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38979709/

相关文章:

grails - 在表列中查找最大值

html - <g:if>和<g:set>在grails中的误解

grails - Grails插件配置被应用覆盖

grails - 从环境变量将grails配置外部化为多个属性文件

javascript - 在 grails 项目中使用 jquery 2.2.2

grails - 从Groovy中的对象列表中收集值

grails - Grails 中的电子邮件验证

grails - ldap.rememberMe.usernameMapper.userDnBase(多个实例?)(searchSubtree 搜索能力)

hibernate - Multi-Tenancy Grails插件-grails.plugin.multitenant.core.exception.NoCurrentTenantException

grails - 如何在 grails 1.3.5 中从 war 中排除某些插件