1 回答

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超13個(gè)贊
您必須在應(yīng)用程序中啟用存儲(chǔ)庫:
@SpringBootApplication
@EnableJpaRepositories
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
另請(qǐng)確保添加:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
更新:您必須配置數(shù)據(jù)庫連接和驅(qū)動(dòng)程序。H2 示例(在內(nèi)存數(shù)據(jù)庫中)
添加新的依賴項(xiàng):
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
在 application.properties 中添加:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
添加回答
舉報(bào)