我有一个简单的带有 JPA、Web 和 PostgreSQL 的 Spring Boot 项目。我正在使用最新的 Spring Boot 版本2.1.3.RELEASE。
添加简单的 JpaRepository 应用程序后启动失败并出现以下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field dataMappingRepository in com.my.example.service.impl.SimpleServiceImpl required a bean named 'entityManagerFactory' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
我有一个简单的@Service 类,例如:
public class SimpleServiceImpl implements SimpleService {
@Autowired private SimpleJpaRepository repo;
}
和 JpaRepository:
public interface SimpleJpaRepository extends JpaRepository<SimpleEntity, Long> {}
这是我的application.yml:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/simple
username: user
password: pass
driver-class-name: org.postgresql.Driver
jpa:
show-sql: false
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate:
ddl-auto: validate
如果我将spring-boot-starter-parent更改为2.0.8.RELEASE应用程序将正确启动。
千巷猫影
POPMUISE
相关分类