3

I try to change spring-boot-starter-parent from 2.6.9 to 2.7.2. Spring-boot-autoconfigure also changes to 2.7.2 together with parent.

I have a bean which injected the bean EntityManagerFactoryBuilder

@Primary
@Bean(name = "localEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
    return builder
          .dataSource(localDataSource())
          .packages("entity.local")
          .build();
}

When I used 2.7.2 version, Intellij Idea wrote me

Could not autowire. No beans of 'EntityManagerFactoryBuilder' type found.

When I am running my App, I see this

Parameter 0 of method entityManagerFactory in ***.config.db.LocalDataSourceConfig required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found.

and

Action: Consider defining a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' in your configuration.

But 2.6.9 version has not got this problem.

How can I get this bean or what should I can do?

my pom.xml

   <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.9</version>
        <relativePath/>
    </parent>

    <dependencies>
    <!-- spring-boot-starter -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>


    <!-- database -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vladmihalcea</groupId>
        <artifactId>hibernate-types-52</artifactId>
        <version>${hibernate.types.52.version}</version>
    </dependency>
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>
polyackov_ot
  • 103
  • 5
  • 1
    Add your pom.xml also. – Anish B. Sep 08 '22 at 05:45
  • I fixed the problem. I added postfix to datasource.url: "***trustServerCertificate=true;" And it turned out like this jdbc:sqlserver://some-host:;databaseName=some-name;encrypt=true;trustServerCertificate=true; – polyackov_ot Apr 21 '23 at 04:28
  • Intellij Idea continue show me error message, but it is bag and if update it this problem should remove – polyackov_ot Apr 21 '23 at 04:32

0 Answers0