2017-10-17 192 views
0

我通常在standalone.xml上市一樣(只是一個樣本)我的數據源指定它:使用本地數據源,而不是在standalone.xml(WildFly)

<datasource jta="false" jndi-name="java:jboss/datasources/myDB" pool-name="myDB" enabled="true" use-ccm="false"> 
    <connection-url>jdbc:mysql://mysql/myDB</connection-url> 
    <driver>mysql</driver> 
    <security> 
     <user-name>root</user-name> 
     <password>password</password> 
    </security> 
    <validation> 
     <validate-on-match>false</validate-on-match> 
     <background-validation>false</background-validation> 
    </validation> 
    <statement> 
     <share-prepared-statements>false</share-prepared-statements> 
    </statement> 
</datasource> 

MySQL驅動程序安裝到WildFly。我知道,一個可以添加數據源到webapp --> WEB-INF --> my-ds.xml

但是當我部署我buildet戰WildFly我得到

16:59:15,121 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 3) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "poc")]) - failure description: { 
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mysql"], 
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.data-source.\"jboss.naming.context.java.jboss.datasources.testDB\" is missing [jboss.jdbc-driver.mysql]"] 
} 
16:59:15,124 ERROR [org.jboss.as.server] (management-handler-thread - 3) WFLYSRV0021: Deploy of deployment "poc.war" was rolled back with the following failure message: 
{ 
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mysql"], 
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.data-source.\"jboss.naming.context.java.jboss.datasources.testDB\" is missing [jboss.jdbc-driver.mysql]"] 
} 

我的問題是:

我如何才能將我的數據源定義從standalone.xml到我的項目,並使其部署到WildFly時工作

+0

你是如何安裝mysql驅動程序的? –

+0

它作爲一個模塊安裝,我已經解決了這個問題 – x4k3p

+0

你有嗎? WildFly配置中驅動程序的名稱是什麼?請運行jboss-cli.sh並將'ls subsystem = datasources'的輸出添加到您的問題中,因爲您似乎沒有名爲'mysql'的驅動程序。 –

回答

0

已經想出瞭如何解決這個問題。

首先是添加boss-deployment-structure.xml(以WEB-INF遠東),其中一個具有指定驅動程序:

<?xml version="1.0"?> 
<jboss-deployment-structure> 
    <deployment> 
     <dependencies> 
      <module name="com.mysql" services="export"> 
       <imports> 
        <include path="META-INF**"/> 
        <include path="com**"/> 
        <!-- assuming user of the driver is com.something --> 
       </imports> 
      </module> 
     </dependencies> 
    </deployment> 
</jboss-deployment-structure> 

然後,我通過-ds.xml模式加我的數據源。 (WildFly 10說實際上已經廢棄......)

在我的persistence.xml我現在可以使用數據源。

-1

而不是將數據源,-ds.xml放在應用程序中,您可以將它放在部署目錄中。

相關問題