我根据“application- {profile} .properties”文件的配置以及Spring Boot在类路径上检测到的JAR依赖关系,将Spring Boot 1.4.2与依赖于配置文件的自动生成数据源结合使用:
“ pom.xml ”中的Maven Spring Boot依赖项:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</dependency>
</dependencies>
Spring Boot“ application-dev.properties ”:
# JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration)
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database=default
spring.jpa.show-sql=true
spring.jpa.hibernate.naming.strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.continue-on-error=false
spring.datasource.generate-unique-name=false
启动Spring Boot应用程序时,Hibernate应自动生成Derby DDL和底层架构I get the same error reported here:
java.sql.SQLSyntaxErrorException:架构“SA”不存在
生成的JDBC Derby URL和用户名如下所示:
重要:将默认“ spring.jpa.hibernate.ddl-auto ”从“ create-drop ”切换为“< strong>更新“DDL执行有效。但是:根据Spring Boot documentation,“ create-drop ”是嵌入式数据库(如DERBY)的默认设置 - 即使没有配置“spring”。 jpa.hibernate.ddl-auto“明确地。
使用“更新”设置传递DDL后,“create-drop”的前一次运行成功。
有没有一种方法可以让Spring Boot中自动生成的数据源方法与DERBY等嵌入式数据库的“create-drop”一起使用,而不使用这种解决方法?