WildFly 31.0.0。从 IntelliJ 启动时,最终数据源配置失败,未找到 MySQL 驱动程序(作为模块)

问题描述 投票:0回答:1

我想我已经这样做了几十次了。安装本地WildFly,添加MySQL驱动程序作为WildFly连接本地数据库实例的模块。这是针对 WildFly 31.0.0.Final 的。

这是

standalone.xml

    <subsystem xmlns="urn:jboss:domain:datasources:7.1">
        <datasources>
            <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
                <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=${wildfly.h2.compatibility.mode:REGULAR}</connection-url>
                <driver>h2</driver>
                <security user-name="sa" password="sa"/>
            </datasource>
            <datasource jndi-name="java:jboss/datasources/BBStatsDS" pool-name="BBStatsDS">
                <connection-url>jdbc:mysql://localhost:3306/bbstats</connection-url>
                <driver>mysql</driver>
                <security user-name="root" password="yippieyahey"/>
            </datasource>
            <drivers>
                <driver name="h2" module="com.h2database.h2">
                    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                </driver>
                <driver name="mysql" module="com.mysql">
                    <driver-class>com.mysql.cj.jdbc.Driver</driver-class>
                    <xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>
    </subsystem>

我在

com/mysql/main
下将MySQL连接器驱动程序安装到WildFly:

module.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright The WildFly Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->
<module name="com.mysql" xmlns="urn:jboss:module:1.9">
    <resources>
        <resource-root path="mysql-connector-j-8.3.0.jar" />
    </resources>
    
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api "/>
    </dependencies>
</module>

我在管理控制台中仔细检查了驱动程序,看起来没问题:

但是当我启动服务器(从 IntelliJ)时,我得到:

09:49:31,266 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "BBStatsDS")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mysql"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "service jboss.data-source.\"jboss.naming.context.java.jboss.datasources.BBStatsDS\" is missing [jboss.jdbc-driver.mysql]",
        "service jboss.driver-demander.java:jboss/datasources/BBStatsDS is missing [jboss.jdbc-driver.mysql]"
    ]
}
09:49:31,267 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "BBStatsDS")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "jboss.jdbc-driver.mysql",
        "jboss.jdbc-driver.mysql"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "service jboss.data-source.\"jboss.naming.context.java.jboss.datasources.BBStatsDS\" is missing [jboss.jdbc-driver.mysql]",
        "service jboss.driver-demander.java:jboss/datasources/BBStatsDS is missing [jboss.jdbc-driver.mysql]",
        "service jboss.data-source.\"jboss.naming.context.java.jboss.datasources.BBStatsDS\" is missing [jboss.jdbc-driver.mysql]"
    ]
}
09:49:31,272 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:jboss/datasources/BBStatsDS, service jboss.data-source."jboss.naming.context.java.jboss.datasources.BBStatsDS"] 
WFLYCTL0448: 2 additional services are down due to their dependencies being missing or failed

编辑:

通过

standalone.sh
启动与我所看到的没有任何区别:

问:

怎么了?

服务器对于驱动程序来说是否太新?

jakarta-ee wildfly mysql-connector
1个回答
0
投票

我在本地测试了以下内容,这对我有用。注意我刚刚使用了 MySQL 的 docker 版本。

module add --name=com.mysql --resources=~/Downloads/mysql-connector-j-8.3.0/mysql-connector-j-8.3.0.jar --dependencies=java.se,java.logging,javax.sql.api,jakarta.transaction.api
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql, driver-module-name=com.mysql)
/subsystem=datasources/data-source=mysql:add(driver-name=mysql, jndi-name="java:jboss/jdbc/BBStatsDS", enabled=true, connection-url="jdbc:mysql://localhost:3306/test", user-name=testuser, password=testpassword)

上面的作用是使用 CLI 添加模块、添加驱动程序并配置数据源。当我测试数据源时,它似乎有效:

[standalone@localhost:9990 /] /subsystem=datasources/data-source=mysql:test-connection-in-pool
{
    "outcome" => "success",
    "result" => [true]
}
© www.soinside.com 2019 - 2024. All rights reserved.