簡體   English   中英

Wildfly 10.1.0 - 找不到Mysql數據源

[英]Wildfly 10.1.0 - Mysql Datasource not found

我知道,這個問題是建立在所有谷歌和stackoverflow,但我的問題沒有解決,我沒有找到解決方案= /

所以,很簡單,我的WildFly似乎沒有看到我的mysql連接器。

我嘗試使用mysql-connector-java-5.1.38

module.xml(wildfly-10.1.0.Final \\ modules \\ system \\ layers \\ base \\ com \\ mysql \\ main)

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.mysql">
    <resources>
        <resource-root path="mysql-connector-java-5.1.38.jar"/>
    </resources>

    <dependencies>
        <modue name="javax.api"/>
    </dependencies>
</module>

在mysql-connector-java-5.1.38上嘗試使用和不使用“.jar”

數據源

<datasources>
    <datasource jndi-name="java:/budget-datasource" pool-name="budget-datasource" enabled="true" use-java-context="true" use-ccm="true">
        <connection-url>jdbc:mysql://127.0.0.1:3306/budget?zeroDateTimeBehavior=convertToNull</connection-url>
        <driver>mysql</driver>
        <security>
            <user-name>root</user-name>
        </security>
    </datasource>
    <drivers>
        <driver name="mysql" module="com.mysql">
            <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
        </driver>
    </drivers>
</datasources>

我試着替換

<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>

通過

<driver>com.mysql.jdbc.Driver</driver>

但沒有奏效

完整有趣的堆棧跟蹤ERROR [org.jboss.as.controller.management-operation](ServerService線程池 - 33)WFLYCTL0013:操作(“添加”)失敗 - 地址:([(“subsystem”=>“datasources”) ,(“jdbc-driver”=>“mysql”)

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "budget-datasource")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mysql"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]",
        "jboss.driver-demander.java:/budget-datasource is missing [jboss.jdbc-driver.mysql]"
    ]
}

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "budget-datasource")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "jboss.jdbc-driver.mysql",
        "jboss.jdbc-driver.mysql"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]",
        "jboss.driver-demander.java:/budget-datasource is missing [jboss.jdbc-driver.mysql]",
        "org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]"
    ]
}

INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.driver-demander.java:/budget-datasource, service org.wildfly.data-source.budget-datasource] 

我使用Eclipse Mars來開發,需要配置項目才能使用mysql連接器嗎?

在此之前,非常感謝你們的幫助,我很失落

我找到了解決方案:

<modue name="javax.api"/>

<module name="javax.api"/>

除了創建一個mysql模塊,嘗試另一種方式:

1)在Wildfly上部署jar mysql-connector-java-5.1.38.jar

2)如下設置數據源

 <datasources>
    <datasource jndi-name="java:/budget-datasource" pool-name="budget-datasource" enabled="true" use-java-context="true" use-ccm="true">
        <connection-url>jdbc:mysql://127.0.0.1:3306/budget?zeroDateTimeBehavior=convertToNull</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <driver>mysql-connector-java-5.1.38.jar</driver>
        <security>
            <user-name>root</user-name>
        </security>
    </datasource>
</datasources>
Absent one mandatory step : you need to reference the module as a driver in WildFly configuration with the following jboss-cli command.

The Command Line

All admin operations can be also done through the command line. To activate WildFly command line prompt start WildFly, go to the WILDFLY_HOME/bin folder and execute the command:

#> jboss-cli.sh(.bat) --connect

It connects to localhost and port 9990 by default. The prompt looks like [standalone@localhost:9990 /], indicating it is ready to accept admin commands. Type quit when you are done. Command line examples are spreaded througout the text. Before using them, please remove all line breaks and identation spaces, making them a continous text string. For example:

Instead of doing exactly this:

[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(
    driver-name=mysql,
    driver-module-name=com.mysql,
    driver-class-name=com.mysql.jdbc.Driver
)

You should do this:

[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-class-name=com.mysql.jdbc.Driver)

這將解決問題,並且驅動器出現在WildFly 10的已注冊驅動程序列表中

在您的model.xml上,只需定義:

<resources>
    <resource-root path="mysql-connector-java-8.0.11.jar"/>
</resources>

<dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
</dependencies>

針對此問題的一種解決方案:編輯standalone.xml,在bloc中添加此行

<driver name="mysql" module="com.mysql"/>

<drivers>
        <driver name="mysql" module="com.mysql"/>
</drivers>`

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM