亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JPA、Wildfly 14 和 PostgreSQL

JPA、Wildfly 14 和 PostgreSQL

喵喔喔 2021-12-22 15:33:25
我正在嘗試使用 JPA 和 Wildfly 14 作為網絡服務器連接到我的 PostgreSQL 數據庫。我跟著幾個教程,但我總是得到:找不到名為“test”的持久性單元我做了什么:下載 postgresql-42.2.5.jar 并將其復制到同一目錄中的“wildfly-14.0.1.Final\modules\system\layers\base\org\postgres\main\”module.xml<?xml version="1.0" encoding="UTF-8"?><module xmlns="urn:jboss:module:1.3" name="org.postgresql">    <resources>        <resource-root path="postgresql-42.2.5.jar"/>        <!-- Make sure this matches the name of the JAR you are installing -->    </resources>    <dependencies>        <module name="javax.api"/>        <module name="javax.transaction.api"/>    </dependencies></module>然后修改了standallone-full.xml<datasource jta="true" jndi-name="java:jboss/datasources/test" pool-name="test" enabled="true" use-ccm="true">  <connection-url>jdbc:postgresql://localhost:5432/test</connection-url>  <driver-class>org.postgresql.Driver</driver-class>  <driver>postgres</driver>  <security>      <user-name>postgres</user-name>      <password>8a6rbd7a5c3a3fsavf4rq</password>  </security>和<driver name="postgres" module="org.postgres">    <driver-class>org.postgresql.Driver</driver-class></driver>現在的persistence.xml<?xml version="1.0" encoding="UTF-8"?>    <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>在那之后,當然,有點java:@PersistenceContext(unitName = "test")private EntityManager em;所以,這就是我所做的 - 但嘗試了更多......在部署中出現了錯誤:WFLYWELD0037:將持久性單元注入 CDI 托管 bean 時出錯。在部署中找不到名為“test”的持久性單元...我不知道該怎么做。我是否忘記了一些 Maven 依賴項?
查看完整描述

1 回答

?
ABOUTYOU

TA貢獻1812條經驗 獲得超5個贊

namemodule.xml有匹配的路徑。(無主)

將其更改為 <module xmlns="urn:jboss:module:1.3" name="org.postgres">

編輯:

另外推薦的放置模塊的地方是直接放入 $JBOSS_HOME\modules

所以在你的情況下: $JBOSS_HOME\modules\org\postgres\main\


查看完整回答
反對 回復 2021-12-22
  • 1 回答
  • 0 關注
  • 163 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號