JPA: Spring Boot will not search for `META-INF/persistence.xml`

What I learned today — 21 August 2018

Niel de Wet
1 min readAug 21, 2018

Spring Boot will now ignore persistence.xml and orm.xml files by default. From the documentation:

Spring Boot will not search for or use a META-INF/persistence.xml by default. If you prefer to use a traditional persistence.xml, you need to define your own @Bean of type LocalEntityManagerFactoryBean (with an ID of ‘entityManagerFactory’) and set the persistence unit name there.

This also means that you can’t use orm.xml to override annotations on your entities without configuring this bean. Doing that in a boot app may not be trivial.

Here are two examples of how the could be done: One, two.

--

--

Responses (1)