我正在尝试将Spring Boot 1.5.9升级到2.0.3,并且该服务无法启动并出现以下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Method mvcConversionService in org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
Process finished with exit code 1
该服务在Spring Boot 1.5.9中正常启动。
以下是yaml文件:
spring:
application:
name: customer-crud-application
datasource:
url: jdbc:jtds:sqlserver://localhost:1433;databaseName=db-data-dev
username: sa
password: pwd
driverClassName: net.sourceforge.jtds.jdbc.Driver
jpa:
show-sql: true
hibernate:
dialect: org.hibernate.dialect.SQLServer2012Dialect
server:
port: 8080
max-http-header-size: 65536
和gradle.build
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile versions.lombok
compile('net.sourceforge.jtds:jtds')
compile versions.spring_jdbc
compile versions.spring_boot_starter_data_jpa
}
该项目是使用Spring Boot 2.0成功构建的,并且我已经清理了c:/ Users / {user} /。m2文件夹和intelliJ缓存。请帮忙!
答案 0 :(得分:2)
I had this issue. When I checked maven build log I have realized that there was an error about hibernate packages about
"invalid LOC header (bad signature)".
I solved by deleting sub directories under
<user-home>\.m2\repository\org\hibernate\hibernate-core and recompiling my project.
答案 1 :(得分:2)
@刘晓东..像这样
spring:
jpa:
show-sql: true
database: MYSQL
hibernate:
ddl-auto: update
dialect:
storage_engine: innodb
datasource:
url: jdbc:mysql://localhost:3306/databasename?useSSL=false
username: user
password: password
server:
port: 9999
答案 2 :(得分:1)
添加以下内容。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>