spring 引导中 apache derby 的配置问题
Configuration issue with apache derby in spring boot
在我的 spring 基于引导的应用程序中,我的 pom.xml 中有以下内容:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
当我启动应用程序时,出现以下错误:
APPLICATION FAILED TO START
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
由于pom中有依赖,所以classpath中肯定已经有。那么这里可能是什么问题?
编辑:我没有在 application.properties 中添加任何与 apache derby 相关的配置。我知道我们不需要为嵌入式数据库做这件事。还是我们需要?
derby 需要一些数据源参数,例如 url 用于启动嵌入式服务器。
尝试在 application.properties
中包含 jpa/hibernate 配置详细信息
示例:
# Show or not log for each sql query
spring.jpa.show-sql=true
# Hibernate ddl auto (create, create-drop, update): with "create-drop" the database
# schema will be automatically created afresh for every start of application
spring.jpa.hibernate.ddl-auto=create-drop
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyDialect
在我的 spring 基于引导的应用程序中,我的 pom.xml 中有以下内容:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
当我启动应用程序时,出现以下错误:
APPLICATION FAILED TO START
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
由于pom中有依赖,所以classpath中肯定已经有。那么这里可能是什么问题?
编辑:我没有在 application.properties 中添加任何与 apache derby 相关的配置。我知道我们不需要为嵌入式数据库做这件事。还是我们需要?
derby 需要一些数据源参数,例如 url 用于启动嵌入式服务器。
尝试在 application.properties
中包含 jpa/hibernate 配置详细信息示例:
# Show or not log for each sql query
spring.jpa.show-sql=true
# Hibernate ddl auto (create, create-drop, update): with "create-drop" the database
# schema will be automatically created afresh for every start of application
spring.jpa.hibernate.ddl-auto=create-drop
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyDialect