如何在Wildfly 10上设置MariaDB JNDI?

我正在尝试将Tomcat Web服务移动到Wildfly10。我认为应该将其拖放到Wildfly的部署文件夹中,并且一切都应该没问题,但似乎并非如此。

这是我的MariaDB数据源定义standalone.xml

<datasource jndi-name="java:jboss/MariaDBDS" pool-name="MariaDBDS">

<connection-url>jdbc:mariadb://db_ip/db_name</connection-url>

<driver>mariadb</driver>

<security>

<user-name>dbAcc</user-name>

<password>dbPassword</password>

</security>

<validation>

<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>

<validate-on-match>true</validate-on-match>

<background-validation>false</background-validation>

<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>

</validation>

</datasource>

<drivers>

<driver name="mariadb" module="org.mariadb">

<driver-class>org.mariadb.jdbc.Driver</driver-class>

<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>

</driver>

</drivers>

然后我将mariadb-java-

client-1.4.6.jarWAR文件放入wildfly/standalone/deployments,启动Wildfly,并出现错误消息:

07:05:21,137 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 60) WFLYUT0021: Registered web context: /MySV

07:05:21,143 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([

("subsystem" => "datasources"),

("data-source" => "MariaDBDS")

]) - failure description: {

"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mariadb"],

"WFLYCTL0180: Services with missing/unavailable dependencies" => [

"jboss.driver-demander.java:jboss/MariaDBDS is missing [jboss.jdbc-driver.mariadb]",

"org.wildfly.data-source.MariaDBDS is missing [jboss.jdbc-driver.mariadb]"

]

}

07:05:21,148 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([

("subsystem" => "datasources"),

("data-source" => "MariaDBDS")

]) - failure description: {

"WFLYCTL0412: Required services that are not installed:" => [

"jboss.jdbc-driver.mariadb",

"jboss.jdbc-driver.mariadb"

],

"WFLYCTL0180: Services with missing/unavailable dependencies" => [

"jboss.driver-demander.java:jboss/MariaDBDS is missing [jboss.jdbc-driver.mariadb]",

"org.wildfly.data-source.MariaDBDS is missing [jboss.jdbc-driver.mariadb]",

"org.wildfly.data-source.MariaDBDS is missing [jboss.jdbc-driver.mariadb]"

]

}

我不能让我的服务连接到数据库,是否错过了任何步骤?

回答:

如果我查看您的配置,则将驱动程序设置为模块。因此,您可以在服务器中将其创建为模块,而不是将其作为单独的jar部署到Deployments文件夹中。

如果要设置驱动程序在Deployments文件夹中的数据源,请执行以下操作:

<datasource jndi-name="java:jboss/MariaDBDS" pool-name="MariaDBDS">

<connection-url>jdbc:mariadb://db_ip/db_name</connection-url>

<driver>mariadb-java-client-1.4.6.jar</driver>

<driver-class>org.mariadb.jdbc.Driver</driver-class>

<security>

<user-name>dbAcc</user-name>

<password>dbPassword</password>

</security>

<validation>

<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>

<validate-on-match>true</validate-on-match>

<background-validation>false</background-validation>

<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>

</validation>

</datasource>

不需要单独的驱动程序声明,所有声明都包含在数据源配置中。

以上是 如何在Wildfly 10上设置MariaDB JNDI? 的全部内容, 来源链接: utcz.com/qa/410173.html

回到顶部