本文介绍了Grails run-app:任务':bootRun'的执行失败。错误:无法启动服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  | 

运行应用程序...
objc [1566]:Class JavaLaunchHelper在/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java和/ Library / Java / JavaVirtualMachines / jdk1中实现.8.0_60.jdk /内容/首页/ JRE / lib目录/ libinstrument.dylib。将使用两者之一。哪一个是未定义的。
INFO 5/9/16 4:10 PM:liquibase:成功获取变更日志锁
INFO 5/9/16 4:10 PM:liquibase:从PUBLIC.DATABASECHANGELOG读取
SEVERE 5 / 9/16 4:10 PM:liquibase:changelog.groovy:week-5A.groovy :: 1462469938896-1 :: Marco(generated):Change Set week-5A.groovy :: 1462469938896-1 :: Marco(generated)失败。错误:表QUOTE已存在; SQL语句:
CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,version BIGINT NOT NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))[42101-191] [失败的SQL:CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,版本BIGINT不为NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))]
liquibase.exception.DatabaseException:表QUOTE已经存在; SQL语句:
CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,version BIGINT NOT NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))[42101-191] [失败的SQL:CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,版本BIGINT不为NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))]
at liquibase.executor.jvm.JdbcExecutor $ ExecuteStatementCallback.doInStatement( JdbcExecutor.java:301)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:107)
at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1251)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1234)
at liquibase.changelog.ChangeSet.execute(ChangeSet .java:554)
在liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
在liquibase.changelog.Chan geLogIterator.run(ChangeLogIterator.java:73)
在liquibase.Liquibase.update(Liquibase.java:212)
在liquibase.Liquibase.update(Liquibase.java:192)
在liquibase .integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434)
at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:80)
at liquibase.integration.spring .SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support .AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support .AbstractAutowireCa pableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support .DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support .AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext .finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.contex t.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext( SpringApplication.java:361)
在org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
在grails.boot.GrailsApp.run(GrailsApp.groovy:55)
在grails.boot.GrailsApp.run(GrailsApp.groovy:365)
在grails.boot.GrailsApp.run(GrailsApp.groovy:354)
在grails.boot.GrailsApp $ run.call(未知源)
在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
在org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at qotd.Application.main(Application.groovy:8)
由$ :org.h2.jdbc.JdbcSQLExc eption:表QUOTE已经存在; SQL语句:
CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,version BIGINT NOT NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))[42101-191]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException。在org.h2.command.CommandContainer.update处获取(DbException.java:155)
(org.h2.command.ddl.CreateTable.update(CreateTable.java:115)
(CommandContainer.java: 98)
在org.h2.command.Command.executeUpdate(Command.java:258)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:184)
at org .h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158)
at liquibase.executor.jvm.JdbcExecutor $ ExecuteStatementCallback.doInStatement(JdbcExecutor.java:299)
... 35 more
INFO 5/9/16 4:10 PM:liquibase:week-5A.groovy :: 1462469938896-1 :: Marco(已生成):已成功发布更改日志锁
ERROR org.springframework.boot.SpringApplication - 应用程序启动失败
org.springframework.beans.factory.BeanCreationException:创建名为'springLiquibase_dataSource'的bean时出错:init方法调用失败;嵌套的异常是liquibase.exception.MigrationFailedException:迁移失败的更改设置week-5A.groovy :: 1462469938896-1 :: Marco(生成):
原因:liquibase.exception.DatabaseException:表QUOTE已存在; SQL语句:
CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,version BIGINT NOT NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))[42101-191] [失败的SQL:CREATE在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory上,$ P





$在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)上
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory中
。 createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry .getSingle ton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory。 getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization( AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext。 java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java :361)
在org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
在grails.boot.GrailsApp.run(GrailsApp.groovy:55)
在grails。在grails.boot.GrailsApp.run(GrailsApp.groovy:354)上
b $ b at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at qotd.Application.main(Application.groovy:8)
由liquibase引起。 exception.MigrationFailedException:迁移失败,更改设置week-5A.groovy :: 1462469938896-1 :: Marco(生成):
原因:liquibase.exception.DatabaseException:表QUOTE已存在; SQL语句:
CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,version BIGINT NOT NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))[42101-191] [失败的SQL:CREATE在变量liquibase.changelog.ChangeSet.execute处更改
(变更集.java:变量名,值为空) 590)
在liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
在liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
在liquibase.Liquibase .update(Liquibase.java:212)
在liquibase.Liquibase.update(Liquibase.java:192)
在liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434)
at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:80)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiq
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean( AbstractAutowireCapableBeanFactory.java:1574)
...省略了21个常见框架
引起:liquibase.exception.DatabaseException:表QUOTE已经存在; SQL语句:
CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,version BIGINT NOT NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))[42101-191] [失败的SQL:CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,版本BIGINT不为NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))]
at liquibase.executor.jvm.JdbcExecutor $ ExecuteStatementCallback.doInStatement( JdbcExecutor.java:301)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:107)
at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1251)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1234)
at liquibase.changelog.ChangeSet.execute(ChangeSet .java:554)
...省略了30个常见框架
引起:org.h2.jdbc.JdbcSQLException:表QUOTE已经存在; SQL语句:
CREATE TABLE PUBLIC.quote(id BIGINT AUTO_INCREMENT NOT NULL,version BIGINT NOT NULL,text VARCHAR(255)NOT NULL,CONSTRAINT quotePK PRIMARY KEY(id))[42101-191]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException。在org.h2.command.CommandContainer.update处获取(DbException.java:155)
(org.h2.command.ddl.CreateTable.update(CreateTable.java:115)
(CommandContainer.java: 98)
在org.h2.command.Command.executeUpdate(Command.java:258)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:184)
at org .h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158)
at liquibase.executor.jvm.JdbcExecutor $ ExecuteStatementCallback.doInStatement(JdbcExecutor.java:299)
... 35个常用框架省略

失败:构建失败,出现异常。

*出错:
任务':bootRun'的执行失败。
>进程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java''以非零退出值1

完成*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。
|错误无法启动服务器(使用--stacktrace查看完整跟踪)

这是我的版本。 gradle文件:

  buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven {urlhttp:// localhost:8081 / nexus / content / groups / public /}
}
dependencies {
classpathorg.grails:grails-gradle-plugin:$ grailsVersion
classpathcom.bertramlabs.plugins:asset-pipeline-gradle:2.7.4
classpathorg.grails。插件:hibernate4:5.0.2
classpathorg.grails.plugins:database-migration:2.0.0.RC4

}

version 1.0.0-SNAPSHOT
组qotd

应用插件:eclipse
应用插件:idea
应用插件:war
apply plugin:org.grails.grails-web
apply plugin:org.grails.grails-gsp
apply plugin:asset-pipeline
apply plugin:基地
apply plugin:java
apply plugin:maven

ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}

仓库{
mavenLocal()
maven {urlhttp:// localhost:8081 / nexus / content / groups / public /}
}

dependencyManagement {
imports {
mavenBomorg.grails:grails-bom:$ grailsVersion
}
applyMavenExclusions false
}

依赖关系{
编译org.springframework.boot:spring-boot-starter-logging
编译org.springframework.boot:spring-boot-autoconfigure
compile org.grails:grails-core
compileorg.springframework.boot:spring-boot-starter-actuator
compileorg.springframework.boot:spring-boot-starter-tomcat
compileorg.grails:grails-dependencies
compileorg.grails:grails-web-boot
compileorg.grails.plugins:cache
compileorg。 GR ails.plugins:脚手架
编译org.grails.plugins:hibernate4
编译org.hibernate:hibernate-ehcache
控制台org.grails:grails-console
profileorg.grails.profiles:web:3.1.4
runtimeorg.grails.plugins:asset-pipeline
runtimecom.h2database:h2
runtime org.grails.plugins:database-migration:2.0.0.RC4
testCompileorg.grails:grails-plugin-testing
testCompileorg.grails.plugins:geb
testRuntimeorg.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1
testRuntimenet.sourceforge.htmlunit:htmlunit:2.18
}
uploadArchives {
repositories {
mavenDeployer {
repository(
url:$ {nexusUrl} / content / repositories / releases){
认证(userName:nexusUsername,
密码:nexusPassword )
}
snapshotRepository(
url:$ {nexus (用户名:nexusUsername,
密码:nexusPassword)
}
}
}
} $ {
authentication / user / repositories / b
$ b任务包装(类型:包装){
gradleVersion = gradleWrapperVersion
}

资产{
minifyJs = true
minifyCss = true

$ b $ sourceSets {
main {
资源{
srcDir'grails-app / migrations'
}
}
}

这是一个每周增量构建的类的项目。本周我们将更新域对象模型并执行数据库迁移。



这是应用程序文件:

  --- 
hibernate:
cache:
queries:false
use_second_level_cache:true
use_query_cache:false
region.factory_class:'org.hibernate.cache.ehcache.EhCacheRegionFactory'

dataSource:
合并:true
jmxExport:true
driverClassName:org.h2.Driver
用户名:sa
密码:

环境:
开发:
dataSource:
dbCreate:
url:jdbc:h2:./ quoteDB; MVCC = TRUE; LOCK_TIMEOUT = 10000; DB_CLOSE_ON_EXIT = TRUE
grails:
插件:
databasemigration:
updateOnStart:true
updateOnStartFileNames:[changelog.groovy]
测试:
dataSource :
dbCreate:update
url:jdbc:h2:mem:testDb; MVCC = TRUE; LOCK_TIMEOUT = 10000; DB_CL OSE_ON_EXIT = FALSE
生产:
dataSource:
dbCreate:update
url:jdbc:h2:./ prodDb; MVCC = TRUE; LOCK_TIMEOUT = 10000; DB_CLOSE_ON_EXIT = FALSE
性质:
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

---
---
grails:
profile:web
codegen:
defaultPackage:qotd
spring:
transactionManagement:
代理:false
info:
app:
名称:'@ info.app.name @'
版本:'@ info.app.version @'
grailsVersion:'@ info.app.grailsVersion @ '
spring:

groovy:
模板:
check-template-location:false

---
grails :
mime:
禁用:
接受:
标题:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
类型:
全部:'* / *'
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
控制器:
defaultScope:singleton
转换器:
编码:UTF-8
视图:
默认值:
编解码器:html
gsp:
编码:UTF-8
htmlcodec:xml
编解码器:
表达式:html
scriptlets:html
taglib:none
staticparts:none
endpoints:
jmx:
unique-names:true

我试过的东西:


  1. gradle clean assemble

  2. 重新启动计算机

  3. 确保我的$ JAVA_HOME变量设置正确

  4. 删除数据库文件(rec。
  5. 不是已经在使用的地址(手动使用 pid 检查)

感谢您的关注!

解决方案

问题是,我的更改日志和第5a周的脚本都在做同样的事情,即创建数据库。在changelog内部,有一行代码表示包含文件:'week-5A.groovy'。所以当更改日志被执行时,它会创建数据库,然后执行第5A周,继续执行相同的操作,从而抛出异常。

Trying to do a bootRun with Gradle but I can't get past this error:

| Running application...
objc[1566]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
INFO 5/9/16 4:10 PM: liquibase: Successfully acquired change log lock
INFO 5/9/16 4:10 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG
SEVERE 5/9/16 4:10 PM: liquibase: changelog.groovy: week-5A.groovy::1462469938896-1::Marco (generated): Change Set week-5A.groovy::1462469938896-1::Marco (generated) failed.  Error: Table "QUOTE" already exists; SQL statement:
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))]
liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement:
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))]
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:301)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:107)
    at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1251)
    at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1234)
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:554)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
    at liquibase.Liquibase.update(Liquibase.java:212)
    at liquibase.Liquibase.update(Liquibase.java:192)
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434)
    at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:80)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:55)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:365)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:354)
    at grails.boot.GrailsApp$run.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at qotd.Application.main(Application.groovy:8)
Caused by: org.h2.jdbc.JdbcSQLException: Table "QUOTE" already exists; SQL statement:
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.command.ddl.CreateTable.update(CreateTable.java:115)
    at org.h2.command.CommandContainer.update(CommandContainer.java:98)
    at org.h2.command.Command.executeUpdate(Command.java:258)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:184)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:299)
    ... 35 more
INFO 5/9/16 4:10 PM: liquibase: week-5A.groovy::1462469938896-1::Marco (generated): Successfully released change log lock
ERROR org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springLiquibase_dataSource': Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set week-5A.groovy::1462469938896-1::Marco (generated):
     Reason: liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement:
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:55)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:365)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:354)
    at grails.boot.GrailsApp$run.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at qotd.Application.main(Application.groovy:8)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set week-5A.groovy::1462469938896-1::Marco (generated):
     Reason: liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement:
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))]
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:590)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
    at liquibase.Liquibase.update(Liquibase.java:212)
    at liquibase.Liquibase.update(Liquibase.java:192)
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434)
    at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:80)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    ... 21 common frames omitted
Caused by: liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement:
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))]
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:301)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:107)
    at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1251)
    at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1234)
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:554)
    ... 30 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLException: Table "QUOTE" already exists; SQL statement:
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.command.ddl.CreateTable.update(CreateTable.java:115)
    at org.h2.command.CommandContainer.update(CommandContainer.java:98)
    at org.h2.command.Command.executeUpdate(Command.java:258)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:184)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:299)
    ... 35 common frames omitted

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
| Error Failed to start server (Use --stacktrace to see the full trace)

This is my build.gradle file:

buildscript {
    ext {
        grailsVersion = project.grailsVersion
    }
    repositories {
        mavenLocal()
        maven { url "http://localhost:8081/nexus/content/groups/public/" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.7.4"
        classpath "org.grails.plugins:hibernate4:5.0.2"
     classpath "org.grails.plugins:database-migration:2.0.0.RC4"
    }
}

version "1.0.0-SNAPSHOT"
group "qotd"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"
apply plugin:"base"
apply plugin:"java"
apply plugin:"maven"

ext {
    grailsVersion = project.grailsVersion
    gradleWrapperVersion = project.gradleWrapperVersion
}

repositories {
    mavenLocal()
        maven { url "http://localhost:8081/nexus/content/groups/public/" }
}

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.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:3.1.4"
    runtime "org.grails.plugins:asset-pipeline"
    runtime "com.h2database:h2"
    runtime "org.grails.plugins:database-migration:2.0.0.RC4"
    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"
}
uploadArchives{
    repositories{
        mavenDeployer{
            repository(
            url: "${nexusUrl}/content/repositories/releases"){
                authentication(userName: nexusUsername,
                           password: nexusPassword)
            }
            snapshotRepository(
            url: "${nexusUrl}/content/repositories/snapshots"){
                authentication(userName: nexusUsername,
                           password: nexusPassword)
            }
        } 
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = gradleWrapperVersion
}

assets {
    minifyJs = true
    minifyCss = true
}

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

This is a project for class that gets built incrementally each week. This week we are to update the domain object model and perform a database migration.

This is the application file:

---
hibernate:
    cache:
        queries: false
        use_second_level_cache: true
        use_query_cache: false
        region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'

dataSource:
    pooled: true
    jmxExport: true
    driverClassName: org.h2.Driver
    username: sa
    password:

environments:
    development:
        dataSource:
            dbCreate: ""
            url: jdbc:h2:./quoteDB;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=TRUE
        grails:
            plugin:
                databasemigration:
                    updateOnStart: true
                    updateOnStartFileNames: [changelog.groovy]
    test:
        dataSource:
            dbCreate: update
            url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
    production:
        dataSource:
            dbCreate: update
            url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
            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

---
---
grails:
    profile: web
    codegen:
        defaultPackage: qotd
    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:
    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

Things I've tried:

  1. gradle clean assemble
  2. Restarting computer
  3. Making sure my $JAVA_HOME variable was correctly set
  4. Deleting the database files (rec. by professor)
  5. Not a case of address already in use(manually check using pid)

Thanks for taking a look!

解决方案

The problem was that both my changelog and week-5a scripts were both doing the same thing that is, creating the database. Inside of changelog there was a line of code that said include file: 'week-5A.groovy'. So when changelog was executed it create the database and then executed week-5A which proceeded to do the same thing and thus the exception was thrown.

这篇关于Grails run-app:任务':bootRun'的执行失败。错误:无法启动服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:01