我有一个Spring Boot项目,我正在设置一些测试。我使用这些细节为'test'设置了一个环境和配置;
spring.jpa.hibernate.ddl-auto = create-drop
spring.jpa.database = HSQL
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.HSQLDialect
spring.datasource.driverClassName = org.hsqldb.jdbcDriver
spring.datasource.url = jdbc:hsqldb:mem:fujitest
spring.datasource.username = sa
spring.datasource.password =
我使用MySQLWorkbench导出了一个数据库,把它放在我的项目根目录中,并命名为'data.sql',但是当我运行我的测试时,我看到了以下错误;
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController': Unsatisfied dependency expressed through field 'db': Error creating bean with name 'repositories': Unsatisfied dependency expressed through field 'oAuthClients': Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: ; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositories': Unsatisfied dependency expressed through field 'oAuthClients': Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token:
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
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:776)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:111)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
... 24 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositories': Unsatisfied dependency expressed through field 'oAuthClients': Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token:
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
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:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1214)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566)
... 42 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token:
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:357)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
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:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1214)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566)
... 56 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token:
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1600)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:580)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:546)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:712)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:685)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:354)
... 68 more
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: DROP TABLE IF EXISTS `account`; nested exception is java.sql.SQLSyntaxErrorException: unexpected token:
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:494)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:231)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:48)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:176)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runDataScripts(DataSourceInitializer.java:120)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.onApplicationEvent(DataSourceInitializer.java:111)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.onApplicationEvent(DataSourceInitializer.java:49)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.postProcessAfterInitialization(DataSourceInitializedPublisher.java:70)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1723)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:113)
... 78 more
Caused by: java.sql.SQLSyntaxErrorException: unexpected token:
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:473)
... 92 more
Caused by: org.hsqldb.HsqlException: unexpected token:
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 95 more
该错误似乎源于它在尝试解析SQL文件时报告“意外令牌”这一事实,但我无法弄清楚如何解决该问题。
以下是我尝试导入的测试SQL文件的示例。
CREATE TABLE `account` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(200) DEFAULT NULL,
`lastname` varchar(200) DEFAULT NULL,
`username` varchar(200) DEFAULT NULL,
`email` text,
`password` text,
`is_active` tinyint(4) DEFAULT NULL,
`roles` varchar(200) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`reset_token` varchar(16) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
我已根据建议添加了额外的日志记录设置,现在输出如下所示;
Hibernate:
drop table account if exists
Hibernate:
drop table account_device if exists
Hibernate:
drop table oauth_client_details if exists
Hibernate:
drop table stores if exists
Hibernate:
drop table template if exists
Hibernate:
create table account (
id integer generated by default as identity (start with 1),
created_at DATETIME,
email varchar(255),
firstname varchar(255),
is_active TINYINT,
lastname varchar(255),
password varchar(255),
reset_token varchar(255),
roles varchar(255),
updated_at DATETIME,
username varchar(255),
primary key (id)
)
Hibernate:
create table account_device (
id integer generated by default as identity (start with 1),
account_id integer,
device_id varchar(255),
primary key (id)
)
Hibernate:
create table oauth_client_details (
client_id varchar(255) not null,
access_token_validity integer,
additional_information varchar(255),
authorized_grant_types varchar(255),
authorities varchar(255),
autoapprove varchar(255),
client_secret varchar(255),
refresh_token_validity integer,
resource_ids varchar(255),
scope varchar(255),
web_server_redirect_uri varchar(255),
primary key (client_id)
)
Hibernate:
create table stores (
id integer generated by default as identity (start with 1),
active TINYINT,
address_line_1 varchar(255),
address_line_2 varchar(255),
county varchar(255),
created_at DATETIME,
kiosk_id varchar(255),
latitude double,
longitude double,
postcode varchar(255),
retailer_name varchar(255),
store_number integer,
telephone varchar(255),
town varchar(255),
updated_at DATETIME,
primary key (id)
)
Hibernate:
create table template (
id integer generated by default as identity (start with 1),
content varchar(255),
created_at DATETIME,
name varchar(255),
updated_at DATETIME,
primary key (id)
)
2018-01-13 09:40:51.247 INFO 64664 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-01-13 09:40:51.599 INFO 64664 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]
2018-01-13 09:40:51.601 WARN 64664 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController': Unsatisfied dependency expressed through field 'db': Error creating bean with name 'repositories': Unsatisfied dependency expressed through field 'oAuthClients': Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: CREATE TABLE `account` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(200) DEFAULT NULL, `lastname` varchar(200) DEFAULT NULL, `username` varchar(200) DEFAULT NULL, `email` text, `password` text, `is_active` tinyint(4) DEFAULT NULL, `roles` varchar(200) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `reset_token` varchar(16) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: required: (; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: CREATE TABLE `account` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(200) DEFAULT NULL, `lastname` varchar(200) DEFAULT NULL, `username` varchar(200) DEFAULT NULL, `email` text, `password` text, `is_active` tinyint(4) DEFAULT NULL, `roles` varchar(200) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `reset_token` varchar(16) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: required: (; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositories': Unsatisfied dependency expressed through field 'oAuthClients': Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: CREATE TABLE `account` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(200) DEFAULT NULL, `lastname` varchar(200) DEFAULT NULL, `username` varchar(200) DEFAULT NULL, `email` text, `password` text, `is_active` tinyint(4) DEFAULT NULL, `roles` varchar(200) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `reset_token` varchar(16) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: required: (; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OAuthClientRepository': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Volumes/WD%20-%20Projects/Projects/The-App-Developers/Fuji%20Rest%20API/target/classes/data.sql]: CREATE TABLE `account` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(200) DEFAULT NULL, `lastname` varchar(200) DEFAULT NULL, `username` varchar(200) DEFAULT NULL, `email` text, `password` text, `is_active` tinyint(4) DEFAULT NULL, `roles` varchar(200) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `reset_token` varchar(16) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: required: (
2018-01-13 09:40:51.601 INFO 64664 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
Hibernate:
drop table account if exists
Hibernate:
drop table account_device if exists
Hibernate:
drop table oauth_client_details if exists
Hibernate:
drop table stores if exists
Hibernate:
drop table template if exists
答案 0 :(得分:0)
我可以在这里看到一个奇怪的冒号
spring.datasource.url: jdbc:hsqldb:mem:fujitest
应该是
spring.datasource.url=jdbc:hsqldb:mem:fujitest
?并且每个属性应该是独立的(可能通过复制在此格式化了格式化)。
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database=HSQL
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect
spring.datasource.driverClassName=org.hsqldb.jdbcDriver
spring.datasource.url=jdbc:hsqldb:mem:fujitest
spring.datasource.username=sa
spring.datasource.password=