简体   繁体   English

使用IntelliJ生成JPA实体而不使用persistence.xml或orm.xml

[英]Generating JPA entities with IntelliJ without a persistence.xml or orm.xml

Is there a way to generate JPA entities with IntelliJ without a persistence.xml file? 有没有办法用IntelliJ生成JPA实体而没有persistence.xml文件? Or basically have IntelliJ recognize a persistance unit from Java Config? 或者基本上让IntelliJ识别来自Java Config的持久性单元? I have an existing (legacy) schema and the project is a rewrite, now using Java Config in Spring Boot. 我有一个现有的(遗留)模式,该项目是一个重写,现在使用Spring Boot中的Java Config。 Per the Spring Boot docs, the persistence unit will be created by code: 根据Spring Boot文档,持久性单元将由代码创建:

@Bean
public LocalContainerEntityManagerFactoryBean customerEntityManagerFactory(
        EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(dataSource())
            .packages(com.abc.DomainThing.class)
            .persistenceUnit("abc")
            .build();
}

我通过在项目中使用persistence.xml解决了这个问题,并没有真正被代码使用或签入。它只是让IDE开心,我可以将数据源绑定到它以获得JPA Entity类中的DB模式帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM