Yeah. Spring Boot should load it by default if orm.xml
exists in META-INF
directory in result jar.
Otherwise it's possible to load it manually by creating custom LocalContainerEntityManagerFactoryBean
as follows below:
Application.properties
spring.jpa.orm=orm.xml
DBConfig.java (In case you use Hibernate as a persistence provider)
@Configuration
public class DBConfig extends HibernateJpaAutoConfiguration {
@Value("${spring.jpa.orm}")
private String orm;
@SuppressWarnings("SpringJavaAutowiringInspection")
public DBConfig(DataSource dataSource, JpaProperties jpaProperties, ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
super(dataSource, jpaProperties, jtaTransactionManagerProvider);
}
@Override
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder factoryBuilder)
{
final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = super.entityManagerFactory(factoryBuilder);
entityManagerFactoryBean.setMappingResources(orm);
return entityManagerFactoryBean;
}
}
I found it quite usefull for me to move all mappings to external xml-files while entities stay clean.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…