gpt4 book ai didi

java - Wildfly-Thorntail 无法连接到 MariaDB

转载 作者:行者123 更新时间:2023-12-02 10:15:18 29 4
gpt4 key购买 nike

我需要将 Wildfly-Thorntail 从 2.2 升级到 2.3,以解决与 Maven 3.6 的兼容性问题。在 Maven 3.5 和 2.2 下,该项目可以完美构建和运行,但在 3.6 下,它会提示“执行 io.thorntail:thorntail-maven-plugin 时遇到 API 不兼容”。

将 Thorntail 更改为 2.3,0 后(为简洁起见,在此处进行硬编码),即

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>bom-all</artifactId>
<version>2.3.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

...程序构建正确,但现在我在程序启动过程中收到此错误:

2019-02-16 21:54:22,159 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 21) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "mysql")
]) - failure description: "WFLYJCA0114: Failed to load datasource class: com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"

下面几行:

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

我的 persistence.xml 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="SPU" transaction-type="JTA">

<!-- The "Java-Transaction-API" datasource here refers to the datasource defined in /src/main/resources/project-defaults.yml. -->
<jta-data-source>java:jboss/datasources/my_ds</jta-data-source>

<!-- User and password defines in project-defaults.yml -->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.show_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>

...在我的 POM 中,我定义了以下连接器:

<!-- The driver used to access MariaDB, automatically detected by Thorntail and registered -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>

由于我对 Wildfly-Thorntail 的了解有限,从今天早上开始我就陷入了困境。任何帮助将不胜感激。

最佳答案

在8.x版本中(这就是你的maven所指示的),MySQL Connector/J中实现java.sql.Driver的类的名称已从com.mysql.jdbc.Driver更改到com.mysql.cj.jdbc.Driver。旧的类名已被弃用。

或者由于您使用 MariaDB 服务器,因此驱动程序是:

    driver-class-name: org.mariadb.jdbc.Driver
xa-datasource-class-name: org.mariadb.jdbc.MariaDbDataSource

与行家:

<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.4.0</version>
</dependency>

关于java - Wildfly-Thorntail 无法连接到 MariaDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54727242/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com