加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – wildfly中的数据源配置10

发布时间:2020-12-13 16:05:57 所属栏目:百科 来源:网络整理
导读:我试图在Mac OS上的Wildfly 10 Application Server中配置PostgreSQL数据源.我正在按照说明书的规定行事.我创建了一个订单: /wildfly-10.1.0.Final/modules/system/layers/base/org/postgresql/main. 按此顺序我放了JDBC驱动程序: postgresql-9.3-1104.jdbc
我试图在Mac OS上的Wildfly 10 Application Server中配置PostgreSQL数据源.我正在按照说明书的规定行事.我创建了一个订单:

/wildfly-10.1.0.Final/modules/system/layers/base/org/postgresql/main.

按此顺序我放了JDBC驱动程序:

postgresql-9.3-1104.jdbc4.jar

我创建了一个module.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql“>
  <resources>
    <resource-root path="postgresql-9.3-1104.jdbc4.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

在standalone.xml文件中,我在datasources下创建了数据源:

<datasource jndi-name="java:jboss/datasources/PostgresDS" pool-name="PostgresDS" enabled="true"
                        use-java-context="true">
   <connection-url>jdbc:postgresql://localhost:5432/testdb</connection-url>
         <driver>postgresql</driver>
            <security>
             <user-name>user</user-name>
             <password>password</password>
            </security>
            <validation>
              <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"></valid-connection-checker>
              <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"></exception-sorter>
     </validation>
   </datasource>

和司机:

<drivers>
   <driver name="postgresql" module="org.postgresql">
     <datasource-class>org.postgresql.Driver</datasource-class>
     <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
   </driver>
</drivers>

但是,不能安装数据源,当我启动服务器时,我收到消息(错误):

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

看来,野生动物可能找不到模块.是什么原因造成了这个问题?我的配置有什么问题吗?

解决方法

我想建议您更改流程.虽然您当然可以手动执行此操作,但如果您编写此脚本,则可以使用可重复性再次执行此操作.

这取决于jboss-cli.sh.我有一个看起来像这样的脚本:

embed-server --std-out=echo --server-config=standalone.xml

batch

module add --name=org.postgres --resources=/tmp/postgresql-42.0.0.jar --dependencies=javax.api,javax.transaction.api

/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)

/subsystem=datasources/data-source=myDataSource/:add(connection-url=jdbc:postgresql://localhost:5432/thedatabasename,driver-name=postgres,jndi-name=java:/jdbc/myDataSource,initial-pool-size=4,max-pool-size=64,min-pool-size=4,password=theDatabasePassword,user-name=theDatabaseUsername)

run-batch

这是运行:

bin/jboss-cli.sh --file=/path/to/file/wildflyconf.cli

该脚本首先使用“embed-server”命令启动,以便您的Wildfly实例不需要运行.然后它启动一批命令作为一个单元运行.

重要的是我们通过命令行创建模块.您必须将PostgreSQL jar放在某处,但除此之外,脚本负责在“modules”下创建所有需要的文件.

接下来,我们添加JDBC驱动程序,然后基于驱动程序创建数据源.

脚本的优点是您可以将其检入源代码控制系统,任何人都可以运行它.它减少了拼写错误的可能性,您无需手动创建和修改文件.

只是一个想法.拥有可重复的流程,您的开发团队可以使用它始终是一件有用的事情.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读