繁体   English   中英

考虑在你的配置中定义一个名为'entityManagerFactory'的bean,升级到spring boot 2后的mssqlserver

[英]Consider defining a bean named 'entityManagerFactory' in your configuration., mssqlserver after upgrade to spring boot 2

我正在尝试将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缓存。 请帮忙!

我有这个问题。 当我检查 maven 构建日志时,我意识到关于休眠包的错误

“无效的 LOC 标头(错误的签名)”。

我通过删除下的子目录来解决

<user-home>\.m2\repository\org\hibernate\hibernate-core and recompiling my project.

请尝试在yaml文件中进行以下更改,

  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

快乐编码.. :)

添加以下部门。

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM