I have a question. My version is 2.4.4, JPA is ok until I use multiply Datasource change have to 'Consider defining a bean named

***************************
APPLICATION FAILED TO START
***************************

Description:

Field actorRepository in com.example.demo.service.impl.ActorServiceImpl 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.

Disconnected from the target VM, address: '127.0.0.1:9383', transport: 'socket'

Process finished with exit code 1

this is my build. Gradle

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'mysql:mysql-connector-java'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    // https://mvnrepository.com/artifact/com.zaxxer/HikariCP
    implementation group: 'com.zaxxer', name: 'HikariCP', version: '3.3.1'
}

My application.yml

spring:
  jpa:
    database: mysql
    show-sql: true
    hibernate:
      ddl-auto: none
#  datasource:
#    driver-class-name: com.mysql.cj.jdbc.Driver
#    jdbc-url: jdbc:mysql://localhost:3306/sakila?serverTimezone=UTC&characterEncoding=UTF-8
#    username: root
#    password: 123456
multiply:
  datasource:
    primary: master
    connect:
      master:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.cj.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sakila?serverTimezone=UTC&characterEncoding=UTF-8
        username: root
        password: 123456
      slave1:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.cj.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sakila?serverTimezone=UTC&characterEncoding=UTF-8
        username: root
        password: 123456
      slave2:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.cj.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sakila?serverTimezone=UTC&characterEncoding=UTF-8
        username: root
        password: 123456

DynamicDataSourceProperties

@Getter
@Setter
@ConfigurationProperties(prefix = "multiply.datasource")
public class DynamicDataSourceProperties {
    /**
     * default data source
     */
    public String primary;

    /**
     * data source map
     */
    public Map<String, DataSourceProperty> connect = new LinkedHashMap<>();

Comment From: xth-bit

JPA is ok if I don't use multiply DataSource change like this

spring:
  jpa:
    database: mysql
    show-sql: true
    hibernate:
      ddl-auto: none
  datasource:
    hikari:
      driver-class-name: com.mysql.cj.jdbc.Driver
      jdbc-url: jdbc:mysql://localhost:3306/sakila?serverTimezone=UTC&characterEncoding=UTF-8
      username: root
      password: 123456

Comment From: philwebb

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.