如何使用独立插件创建一个带有h2 db的独立grails应用程序?

时间:2013-10-26 21:58:19

标签: grails gorm grails-plugin

我正在使用grails独立插件来创建一个独立的grails应用程序,但我得到一个jdbc h2异常。似乎数据库不是在运行时创建的。

我该如何解决这个问题?

这里有例外

org.h2.jdbc.JdbcSQLException: Table "COMPANY" not found; SQL statement:
select this_.id as id15_0_, this_.version as version15_0_, this_.name as name15_0_ from company this_ limit ? [42102-164]

    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)

    at org.h2.message.DbException.get(DbException.java:169)

    at org.h2.message.DbException.get(DbException.java:146)

    at org.h2.command.Parser.readTableOrView(Parser.java:4753)

    at org.h2.command.Parser.readTableFilter(Parser.java:1080)

    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1686)

    at org.h2.command.Parser.parseSelectSimple(Parser.java:1793)

    at org.h2.command.Parser.parseSelectSub(Parser.java:1680)

    at org.h2.command.Parser.parseSelectUnion(Parser.java:1523)

    at org.h2.command.Parser.parseSelect(Parser.java:1511)

    at org.h2.command.Parser.parsePrepared(Parser.java:405)

    at org.h2.command.Parser.parse(Parser.java:279)

    at org.h2.command.Parser.parse(Parser.java:251)

    at org.h2.command.Parser.prepareCommand(Parser.java:217)

    at org.h2.engine.Session.prepareLocal(Session.java:415)

    at org.h2.engine.Session.prepareCommand(Session.java:364)

    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1121)

    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)

    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:267)

    at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281)

    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:313)

    at grails.orm.PagedResultList.<init>(PagedResultList.java:55)

    at com.kodigon.sensexplorer.survey.CompanyController.list(CompanyController.groovy:19)

    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)

    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)

    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)

    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)

    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)

    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)

    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)

    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)

    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at java.lang.Thread.run(Thread.java:744)

2 个答案:

答案 0 :(得分:1)

H2将创建数据库,它可能不会创建您期望的架构。您可以在DataSource.groovy中将以下内容添加到您的URL中:

INIT=CREATE SCHEMA IF NOT EXISTS TEST

所以你有类似的东西:

url = jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;INIT=CREATE SCHEMA IF NOT EXISTS TEST

答案 1 :(得分:-1)

虽然有些旧,但将来可以帮助其他人, 就我而言,只是其中不包含变更日志,因此经过研究

可以帮助我理解类似问题的链接 how to create a standalone grails app with h2 db by using standalone plugin?

说,我创建了一个新迁移,并包含了所生成的迁移,它的工作就像一个魅力……