英文:
Why Quarkus-Hibernate is looking for Persistance.xml when we have already given @DataSource?
问题
我正在尝试构建 Hibernate 项目,并在以下位置指定了属性:
cron.expr=* 12 15 * * ?
quarkus.datasource.driver=oracle.jdbc.driver.OracleDriver
quarkus.hibernate-orm.dialect=oracle.jdbc.driver.OracleDriver
quarkus.datasource.ergo.url=jdbc:oracle:thin:@myhost:1521:orcl
quarkus.datasource.ergo.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.ergo.username=quarkus_test
quarkus.datasource.ergo.password=quarkus_test
quarkus.datasource.mds.url=jdbc:oracle:thin:@myhost:1521:orcl
quarkus.datasource.mds.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.mds.username=quarkus_test
quarkus.datasource.mds.password=quarkus_test
运行后,会在信息中显示以下消息:
HHH000318: Could not find any META-INF/persistence.xml file in the classpath
我应该在 persistence.xml 中写什么?Quarkus 的 persistence.xml 应该是什么样的?在 Java 类中使用 @Datasource 注解时,是否真的需要它?
以下是在之前部署在 Wildfly 中的项目中的 persistence.xml:
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ePU" transaction-type="JTA">
<jta-data-source>java:/datasources/EDS</jta-data-source>
</persistence-unit>
<persistence-unit name="mPU" transaction-type="JTA">
<jta-data-source>java:/datasources/MDS</jta-data-source>
</persistence-unit>
</persistence>
希望这些信息对你有所帮助。
英文:
I am trying to build hibernate project and i have mentioned properties in
cron.expr=* 12 15 * * ?
quarkus.datasource.driver=oracle.jdbc.driver.OracleDriver
quarkus.hibernate-orm.dialect=oracle.jdbc.driver.OracleDriver
quarkus.datasource.ergo.url=jdbc:oracle:thin:@myhost:1521:orcl
quarkus.datasource.ergo.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.ergo.username=quarkus_test
quarkus.datasource.ergo.password=quarkus_test
quarkus.datasource.mds.url=jdbc:oracle:thin:@myhost:1521:orcl
quarkus.datasource.mds.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.mds.username=quarkus_test
quarkus.datasource.mds.password=quarkus_test
After running it is giving following message in info:
HHH000318: Could not find any META-INF/persistence.xml file in the classpath
What shall i write in persistance.xml? How quakus persistance.xml will look like? Is it really required when we are giving @Datasource annotation within java class
Following is persistance.xml in previous project deployed in wildfly:
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ePU" transaction-type="JTA">
<jta-data-source>java:/datasources/EDS</jta-data-source>
</persistence-unit>
<persistence-unit name="mPU" transaction-type="JTA">
<jta-data-source>java:/datasources/MDS</jta-data-source>
</persistence-unit>
</persistence>
答案1
得分: 1
persistence.xml
是可选的,这只是Hibernate发出的一个INFO消息,您可以放心忽略。
Quarkus在构建时启动Hibernate,无需persistence.xml
文件,如果您想要扩展配置,可以添加它,但在大多数情况下是不必要的。
英文:
persistence.xml
is optional, this is just an INFO message from Hibernate that you can safely ignore.
Quarkus bootstrap Hibernate at build time without the need to a persistence.xml
file, you can add it if you want for extended configuration but in most cases this is not needed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论