Spring-boot JPA multiple data-sources is not updating or creating tables












0















I am facing a problem with JPA with spring-boot with multiple data-sources. It is something I have always managed to do. But this time I cannot understand why is not working?



After gradle build or bootRun no table is being created or updated. No compile or run time errors at startup. I am losing my mind.



You can find my code attached.



P2BDatabaseConfig.groovy



@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "p2bEntityManagerFactory",
transactionManagerRef = "p2bTransactionManager",
basePackages = {"it.project.sol.sharpapi.repo.p2b"}
)
public class P2BDatabaseConfig {

@Bean(name = "p2bDataSource")
@ConfigurationProperties(prefix = "spring.p2b")
@Primary
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}

@PersistenceContext(unitName = "p2bPU")
@Bean(name = "p2bEntityManagerFactory")
@Primary
public LocalContainerEntityManagerFactoryBean p2bEntityManagerFactory(EntityManagerFactoryBuilder builder,
@Qualifier("p2bDataSource") DataSource dataSource) {
return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.p2b").build();
}

@Bean(name = "p2bTransactionManager")
@Primary
public PlatformTransactionManager p2bTransactionManager(
@Qualifier("p2bEntityManagerFactory") EntityManagerFactory p2bEntityManagerFactory) {
return new JpaTransactionManager(p2bEntityManagerFactory);
}
}


SharpDatabaseConfig.groovy



@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "sharpEntityManagerFactory",
transactionManagerRef = "sharpTransactionManager",
basePackages = {"it.project.sol.sharpapi.repo.sharp"}
)
public class SharpDatabaseConfig {

@Bean(name = "sharpDataSource")
@ConfigurationProperties(prefix = "spring.sharp")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}

@PersistenceContext(unitName = "sharpPU")
@Bean(name = "sharpEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean sharpEntityManagerFactory(EntityManagerFactoryBuilder builder,
@Qualifier("sharpDataSource") DataSource dataSource) {
return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
}

@Bean(name = "sharpTransactionManager")
public PlatformTransactionManager sharpTransactionManager(
@Qualifier("sharpEntityManagerFactory") EntityManagerFactory sharpEntityManagerFactory) {
return new JpaTransactionManager(sharpEntityManagerFactory);
}
}


application.yml



spring:
profiles:
active: Developement

jpa:
show-sql: true
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
hibernate:
ddl-auto: update
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
dialect: org.hibernate.dialect.MySQL5Dialect

p2b:
url: jdbc:mysql://localhost:3306/p2bv2?autoReconnect=true
username: xxxx
password: xxxx!
testWhileIdle: true
maxActive: 5
validationQuery: SELECT 1
driver-class-name: com.mysql.jdbc.Driver

sharp:
url: jdbc:mysql://localhost:3306/sharp?autoReconnect=true
username: xxxx
password: xxxx!
testWhileIdle: true
maxActive: 5
validationQuery: SELECT 1
driver-class-name: com.mysql.jdbc.Driver


P2BDevice.groovy



@Entity(name = "P2BDevice")
@Table(name = "device")
class P2BDevice implements Serializable{

@Id
@GeneratedValue
Long id

@Column(name = "version")
Long version

@Column(name = "date_created")
Date dateCreated

@Column(name = "deleted")
int deleted

@Column(name = "description")
String description

...

}


User.groovy



@Entity(name = "User")
@Table(name = "caccapupu")
class User implements Serializable{

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id

@Column(name = "version")
Long version

@Column(name = "username")
String username

@Column(name = "password")
Long password

@Column(name = "date_created")
Date dateCreated

@Column(name = "status")
int status

...

}


I can assure you, repositories are correct and even the packages position of my classes.










share|improve this question









New contributor




Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I am facing a problem with JPA with spring-boot with multiple data-sources. It is something I have always managed to do. But this time I cannot understand why is not working?



    After gradle build or bootRun no table is being created or updated. No compile or run time errors at startup. I am losing my mind.



    You can find my code attached.



    P2BDatabaseConfig.groovy



    @Configuration
    @EnableTransactionManagement
    @EnableJpaRepositories(
    entityManagerFactoryRef = "p2bEntityManagerFactory",
    transactionManagerRef = "p2bTransactionManager",
    basePackages = {"it.project.sol.sharpapi.repo.p2b"}
    )
    public class P2BDatabaseConfig {

    @Bean(name = "p2bDataSource")
    @ConfigurationProperties(prefix = "spring.p2b")
    @Primary
    public DataSource dataSource() {
    return DataSourceBuilder.create().build();
    }

    @PersistenceContext(unitName = "p2bPU")
    @Bean(name = "p2bEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean p2bEntityManagerFactory(EntityManagerFactoryBuilder builder,
    @Qualifier("p2bDataSource") DataSource dataSource) {
    return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.p2b").build();
    }

    @Bean(name = "p2bTransactionManager")
    @Primary
    public PlatformTransactionManager p2bTransactionManager(
    @Qualifier("p2bEntityManagerFactory") EntityManagerFactory p2bEntityManagerFactory) {
    return new JpaTransactionManager(p2bEntityManagerFactory);
    }
    }


    SharpDatabaseConfig.groovy



    @Configuration
    @EnableTransactionManagement
    @EnableJpaRepositories(
    entityManagerFactoryRef = "sharpEntityManagerFactory",
    transactionManagerRef = "sharpTransactionManager",
    basePackages = {"it.project.sol.sharpapi.repo.sharp"}
    )
    public class SharpDatabaseConfig {

    @Bean(name = "sharpDataSource")
    @ConfigurationProperties(prefix = "spring.sharp")
    public DataSource dataSource() {
    return DataSourceBuilder.create().build();
    }

    @PersistenceContext(unitName = "sharpPU")
    @Bean(name = "sharpEntityManagerFactory")
    public LocalContainerEntityManagerFactoryBean sharpEntityManagerFactory(EntityManagerFactoryBuilder builder,
    @Qualifier("sharpDataSource") DataSource dataSource) {
    return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
    }

    @Bean(name = "sharpTransactionManager")
    public PlatformTransactionManager sharpTransactionManager(
    @Qualifier("sharpEntityManagerFactory") EntityManagerFactory sharpEntityManagerFactory) {
    return new JpaTransactionManager(sharpEntityManagerFactory);
    }
    }


    application.yml



    spring:
    profiles:
    active: Developement

    jpa:
    show-sql: true
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    hibernate:
    ddl-auto: update
    naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
    dialect: org.hibernate.dialect.MySQL5Dialect

    p2b:
    url: jdbc:mysql://localhost:3306/p2bv2?autoReconnect=true
    username: xxxx
    password: xxxx!
    testWhileIdle: true
    maxActive: 5
    validationQuery: SELECT 1
    driver-class-name: com.mysql.jdbc.Driver

    sharp:
    url: jdbc:mysql://localhost:3306/sharp?autoReconnect=true
    username: xxxx
    password: xxxx!
    testWhileIdle: true
    maxActive: 5
    validationQuery: SELECT 1
    driver-class-name: com.mysql.jdbc.Driver


    P2BDevice.groovy



    @Entity(name = "P2BDevice")
    @Table(name = "device")
    class P2BDevice implements Serializable{

    @Id
    @GeneratedValue
    Long id

    @Column(name = "version")
    Long version

    @Column(name = "date_created")
    Date dateCreated

    @Column(name = "deleted")
    int deleted

    @Column(name = "description")
    String description

    ...

    }


    User.groovy



    @Entity(name = "User")
    @Table(name = "caccapupu")
    class User implements Serializable{

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    Long id

    @Column(name = "version")
    Long version

    @Column(name = "username")
    String username

    @Column(name = "password")
    Long password

    @Column(name = "date_created")
    Date dateCreated

    @Column(name = "status")
    int status

    ...

    }


    I can assure you, repositories are correct and even the packages position of my classes.










    share|improve this question









    New contributor




    Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I am facing a problem with JPA with spring-boot with multiple data-sources. It is something I have always managed to do. But this time I cannot understand why is not working?



      After gradle build or bootRun no table is being created or updated. No compile or run time errors at startup. I am losing my mind.



      You can find my code attached.



      P2BDatabaseConfig.groovy



      @Configuration
      @EnableTransactionManagement
      @EnableJpaRepositories(
      entityManagerFactoryRef = "p2bEntityManagerFactory",
      transactionManagerRef = "p2bTransactionManager",
      basePackages = {"it.project.sol.sharpapi.repo.p2b"}
      )
      public class P2BDatabaseConfig {

      @Bean(name = "p2bDataSource")
      @ConfigurationProperties(prefix = "spring.p2b")
      @Primary
      public DataSource dataSource() {
      return DataSourceBuilder.create().build();
      }

      @PersistenceContext(unitName = "p2bPU")
      @Bean(name = "p2bEntityManagerFactory")
      @Primary
      public LocalContainerEntityManagerFactoryBean p2bEntityManagerFactory(EntityManagerFactoryBuilder builder,
      @Qualifier("p2bDataSource") DataSource dataSource) {
      return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.p2b").build();
      }

      @Bean(name = "p2bTransactionManager")
      @Primary
      public PlatformTransactionManager p2bTransactionManager(
      @Qualifier("p2bEntityManagerFactory") EntityManagerFactory p2bEntityManagerFactory) {
      return new JpaTransactionManager(p2bEntityManagerFactory);
      }
      }


      SharpDatabaseConfig.groovy



      @Configuration
      @EnableTransactionManagement
      @EnableJpaRepositories(
      entityManagerFactoryRef = "sharpEntityManagerFactory",
      transactionManagerRef = "sharpTransactionManager",
      basePackages = {"it.project.sol.sharpapi.repo.sharp"}
      )
      public class SharpDatabaseConfig {

      @Bean(name = "sharpDataSource")
      @ConfigurationProperties(prefix = "spring.sharp")
      public DataSource dataSource() {
      return DataSourceBuilder.create().build();
      }

      @PersistenceContext(unitName = "sharpPU")
      @Bean(name = "sharpEntityManagerFactory")
      public LocalContainerEntityManagerFactoryBean sharpEntityManagerFactory(EntityManagerFactoryBuilder builder,
      @Qualifier("sharpDataSource") DataSource dataSource) {
      return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
      }

      @Bean(name = "sharpTransactionManager")
      public PlatformTransactionManager sharpTransactionManager(
      @Qualifier("sharpEntityManagerFactory") EntityManagerFactory sharpEntityManagerFactory) {
      return new JpaTransactionManager(sharpEntityManagerFactory);
      }
      }


      application.yml



      spring:
      profiles:
      active: Developement

      jpa:
      show-sql: true
      database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
      hibernate:
      ddl-auto: update
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
      dialect: org.hibernate.dialect.MySQL5Dialect

      p2b:
      url: jdbc:mysql://localhost:3306/p2bv2?autoReconnect=true
      username: xxxx
      password: xxxx!
      testWhileIdle: true
      maxActive: 5
      validationQuery: SELECT 1
      driver-class-name: com.mysql.jdbc.Driver

      sharp:
      url: jdbc:mysql://localhost:3306/sharp?autoReconnect=true
      username: xxxx
      password: xxxx!
      testWhileIdle: true
      maxActive: 5
      validationQuery: SELECT 1
      driver-class-name: com.mysql.jdbc.Driver


      P2BDevice.groovy



      @Entity(name = "P2BDevice")
      @Table(name = "device")
      class P2BDevice implements Serializable{

      @Id
      @GeneratedValue
      Long id

      @Column(name = "version")
      Long version

      @Column(name = "date_created")
      Date dateCreated

      @Column(name = "deleted")
      int deleted

      @Column(name = "description")
      String description

      ...

      }


      User.groovy



      @Entity(name = "User")
      @Table(name = "caccapupu")
      class User implements Serializable{

      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      Long id

      @Column(name = "version")
      Long version

      @Column(name = "username")
      String username

      @Column(name = "password")
      Long password

      @Column(name = "date_created")
      Date dateCreated

      @Column(name = "status")
      int status

      ...

      }


      I can assure you, repositories are correct and even the packages position of my classes.










      share|improve this question









      New contributor




      Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I am facing a problem with JPA with spring-boot with multiple data-sources. It is something I have always managed to do. But this time I cannot understand why is not working?



      After gradle build or bootRun no table is being created or updated. No compile or run time errors at startup. I am losing my mind.



      You can find my code attached.



      P2BDatabaseConfig.groovy



      @Configuration
      @EnableTransactionManagement
      @EnableJpaRepositories(
      entityManagerFactoryRef = "p2bEntityManagerFactory",
      transactionManagerRef = "p2bTransactionManager",
      basePackages = {"it.project.sol.sharpapi.repo.p2b"}
      )
      public class P2BDatabaseConfig {

      @Bean(name = "p2bDataSource")
      @ConfigurationProperties(prefix = "spring.p2b")
      @Primary
      public DataSource dataSource() {
      return DataSourceBuilder.create().build();
      }

      @PersistenceContext(unitName = "p2bPU")
      @Bean(name = "p2bEntityManagerFactory")
      @Primary
      public LocalContainerEntityManagerFactoryBean p2bEntityManagerFactory(EntityManagerFactoryBuilder builder,
      @Qualifier("p2bDataSource") DataSource dataSource) {
      return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.p2b").build();
      }

      @Bean(name = "p2bTransactionManager")
      @Primary
      public PlatformTransactionManager p2bTransactionManager(
      @Qualifier("p2bEntityManagerFactory") EntityManagerFactory p2bEntityManagerFactory) {
      return new JpaTransactionManager(p2bEntityManagerFactory);
      }
      }


      SharpDatabaseConfig.groovy



      @Configuration
      @EnableTransactionManagement
      @EnableJpaRepositories(
      entityManagerFactoryRef = "sharpEntityManagerFactory",
      transactionManagerRef = "sharpTransactionManager",
      basePackages = {"it.project.sol.sharpapi.repo.sharp"}
      )
      public class SharpDatabaseConfig {

      @Bean(name = "sharpDataSource")
      @ConfigurationProperties(prefix = "spring.sharp")
      public DataSource dataSource() {
      return DataSourceBuilder.create().build();
      }

      @PersistenceContext(unitName = "sharpPU")
      @Bean(name = "sharpEntityManagerFactory")
      public LocalContainerEntityManagerFactoryBean sharpEntityManagerFactory(EntityManagerFactoryBuilder builder,
      @Qualifier("sharpDataSource") DataSource dataSource) {
      return builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
      }

      @Bean(name = "sharpTransactionManager")
      public PlatformTransactionManager sharpTransactionManager(
      @Qualifier("sharpEntityManagerFactory") EntityManagerFactory sharpEntityManagerFactory) {
      return new JpaTransactionManager(sharpEntityManagerFactory);
      }
      }


      application.yml



      spring:
      profiles:
      active: Developement

      jpa:
      show-sql: true
      database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
      hibernate:
      ddl-auto: update
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
      dialect: org.hibernate.dialect.MySQL5Dialect

      p2b:
      url: jdbc:mysql://localhost:3306/p2bv2?autoReconnect=true
      username: xxxx
      password: xxxx!
      testWhileIdle: true
      maxActive: 5
      validationQuery: SELECT 1
      driver-class-name: com.mysql.jdbc.Driver

      sharp:
      url: jdbc:mysql://localhost:3306/sharp?autoReconnect=true
      username: xxxx
      password: xxxx!
      testWhileIdle: true
      maxActive: 5
      validationQuery: SELECT 1
      driver-class-name: com.mysql.jdbc.Driver


      P2BDevice.groovy



      @Entity(name = "P2BDevice")
      @Table(name = "device")
      class P2BDevice implements Serializable{

      @Id
      @GeneratedValue
      Long id

      @Column(name = "version")
      Long version

      @Column(name = "date_created")
      Date dateCreated

      @Column(name = "deleted")
      int deleted

      @Column(name = "description")
      String description

      ...

      }


      User.groovy



      @Entity(name = "User")
      @Table(name = "caccapupu")
      class User implements Serializable{

      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      Long id

      @Column(name = "version")
      Long version

      @Column(name = "username")
      String username

      @Column(name = "password")
      Long password

      @Column(name = "date_created")
      Date dateCreated

      @Column(name = "status")
      int status

      ...

      }


      I can assure you, repositories are correct and even the packages position of my classes.







      spring-boot jpa groovy






      share|improve this question









      New contributor




      Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 days ago









      Brian Tompsett - 汤莱恩

      4,2031337101




      4,2031337101






      New contributor




      Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      Jude GhenonJude Ghenon

      32




      32




      New contributor




      Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Jude Ghenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Try to explicitly set JPA properties



              LocalContainerEntityManagerFactoryBean em = 
          builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
          HashMap<String, Object> properties = new HashMap<>();
          properties.put("hibernate.hbm2ddl.auto", "update");
          properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
          em.setJpaPropertyMap(properties);





          share|improve this answer
























          • This works, thanks! But i cannot understand why it isn't picking these properties automatically from my application.yml

            – Jude Ghenon
            2 days ago











          • I don't know how spring-boot bootstrapping JPA inside, maybe it's can't mix java configuration with yml/prop or it works only for default JPA bean name i.e "entityManagerFactory"

            – Alexey.S
            2 days ago











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Jude Ghenon is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252452%2fspring-boot-jpa-multiple-data-sources-is-not-updating-or-creating-tables%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try to explicitly set JPA properties



              LocalContainerEntityManagerFactoryBean em = 
          builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
          HashMap<String, Object> properties = new HashMap<>();
          properties.put("hibernate.hbm2ddl.auto", "update");
          properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
          em.setJpaPropertyMap(properties);





          share|improve this answer
























          • This works, thanks! But i cannot understand why it isn't picking these properties automatically from my application.yml

            – Jude Ghenon
            2 days ago











          • I don't know how spring-boot bootstrapping JPA inside, maybe it's can't mix java configuration with yml/prop or it works only for default JPA bean name i.e "entityManagerFactory"

            – Alexey.S
            2 days ago
















          0














          Try to explicitly set JPA properties



              LocalContainerEntityManagerFactoryBean em = 
          builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
          HashMap<String, Object> properties = new HashMap<>();
          properties.put("hibernate.hbm2ddl.auto", "update");
          properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
          em.setJpaPropertyMap(properties);





          share|improve this answer
























          • This works, thanks! But i cannot understand why it isn't picking these properties automatically from my application.yml

            – Jude Ghenon
            2 days ago











          • I don't know how spring-boot bootstrapping JPA inside, maybe it's can't mix java configuration with yml/prop or it works only for default JPA bean name i.e "entityManagerFactory"

            – Alexey.S
            2 days ago














          0












          0








          0







          Try to explicitly set JPA properties



              LocalContainerEntityManagerFactoryBean em = 
          builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
          HashMap<String, Object> properties = new HashMap<>();
          properties.put("hibernate.hbm2ddl.auto", "update");
          properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
          em.setJpaPropertyMap(properties);





          share|improve this answer













          Try to explicitly set JPA properties



              LocalContainerEntityManagerFactoryBean em = 
          builder.dataSource(dataSource).packages("it.project.sol.sharpapi.entity.sharp").build();
          HashMap<String, Object> properties = new HashMap<>();
          properties.put("hibernate.hbm2ddl.auto", "update");
          properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
          em.setJpaPropertyMap(properties);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Alexey.SAlexey.S

          242




          242













          • This works, thanks! But i cannot understand why it isn't picking these properties automatically from my application.yml

            – Jude Ghenon
            2 days ago











          • I don't know how spring-boot bootstrapping JPA inside, maybe it's can't mix java configuration with yml/prop or it works only for default JPA bean name i.e "entityManagerFactory"

            – Alexey.S
            2 days ago



















          • This works, thanks! But i cannot understand why it isn't picking these properties automatically from my application.yml

            – Jude Ghenon
            2 days ago











          • I don't know how spring-boot bootstrapping JPA inside, maybe it's can't mix java configuration with yml/prop or it works only for default JPA bean name i.e "entityManagerFactory"

            – Alexey.S
            2 days ago

















          This works, thanks! But i cannot understand why it isn't picking these properties automatically from my application.yml

          – Jude Ghenon
          2 days ago





          This works, thanks! But i cannot understand why it isn't picking these properties automatically from my application.yml

          – Jude Ghenon
          2 days ago













          I don't know how spring-boot bootstrapping JPA inside, maybe it's can't mix java configuration with yml/prop or it works only for default JPA bean name i.e "entityManagerFactory"

          – Alexey.S
          2 days ago





          I don't know how spring-boot bootstrapping JPA inside, maybe it's can't mix java configuration with yml/prop or it works only for default JPA bean name i.e "entityManagerFactory"

          – Alexey.S
          2 days ago










          Jude Ghenon is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Jude Ghenon is a new contributor. Be nice, and check out our Code of Conduct.













          Jude Ghenon is a new contributor. Be nice, and check out our Code of Conduct.












          Jude Ghenon is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252452%2fspring-boot-jpa-multiple-data-sources-is-not-updating-or-creating-tables%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Callistus III

          Plistias Cous

          Index Sanctorum