• JBoss7 Mysql数据源的建立


    JBoss7.02 相对JBoss4.2.3 变动较大.原来的-ds.xml 数据源配置方式 ,貌似已经不行.

    以下创建步骤 依赖 mysql-connector-java-5.1.17-bin.jar  ,之前一致用 5.0.1的 包,死活不灵光

    1. 创建目录 

    jboss-as-web-7.0.2.Final\modules\com\mysql\main     // "mysql\main"目录需要手动创建

    2. 拷贝mysql-connector-java-5.1.17-bin.jar  到 com\mysql\main\目录下.

    3. com\mysql\main 目录下 , 创建 modules.xml 

    内容:

    <?xml version="1.0" encoding="UTF-8"?>   
    <module xmlns="urn:jboss:module:1.0" name="com.mysql">
    <resources>
    <resource-root path="mysql-connector-java-5.1.17-bin.jar"/>
    </resources>
    <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    </dependencies>
    </module>

    4. 修改配置文件
    jboss-as-web-7.0.2.Final\standalone\configuration\standalone.xml

    找到以下xml配置节点 ,并新增 加粗部分

    <subsystem xmlns="urn:jboss:domain:datasources:1.0">
                <datasources>
                    <datasource jndi-name="java:jboss/datasources/OA_Datasource" pool-name="OA_DS" enabled="true" jta="true" use-java-context="true" use-ccm="true"> <connection-url> jdbc:mysql://localhost:3306/ejbdemo?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false </connection-url> <driver> mysql </driver> <pool> <min-pool-size> 10 </min-pool-size> <max-pool-size> 100 </max-pool-size> <prefill> true </prefill> <use-strict-min> false </use-strict-min> <flush-strategy> FailingConnectionOnly </flush-strategy> </pool> <security> <user-name> root </user-name> <password> </password> </security> <validation> <validate-on-match> false </validate-on-match> <background-validation> false </background-validation> <use-fast-fail> false </use-fast-fail> </validation> </datasource>
                    <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="H2DS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                        <connection-url>
                            jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
                        </connection-url>
                        <driver>
                            h2
                        </driver>
                        <pool>
                            <prefill>
                                false
                            </prefill>
                            <use-strict-min>
                                false
                            </use-strict-min>
                            <flush-strategy>
                                FailingConnectionOnly
                            </flush-strategy>
                        </pool>
                        <security>
                            <user-name>
                                sa
                            </user-name>
                            <password>
                                sa
                            </password>
                        </security>
                    </datasource>
                    <drivers>
                        <driver name="mysql" module="com.mysql"/>
                        <driver name="h2" module="com.h2database.h2">
                            <xa-datasource-class>
                                org.h2.jdbcx.JdbcDataSource
                            </xa-datasource-class>
                        </driver>
                    </drivers>
                </datasources>
            </subsystem>
    

    至于在Jboss Tools 3.3中, 原先的persistence.xml 位置不变,hibernate配置也不变动,如果配置正确,启动时能看到:

    22:29:54,557 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) Bound data source [java:jboss/datasources/OA_Datasource]

    如果配置了hibernate 自动建表,那么还可以看见:

     [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-2) HHH00227:Running hbm2ddl schema export
    22:29:56,118 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-2) HHH00230:Schema export complete

    jboss tools 3.3 ,需要eclipse3.7

    http://download.jboss.org/jbosstools/updates/development/indigo/

    jboss 7.02  Web Profile Only (Java EE6 Certified)
    http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-7.0.2.Final.zip

    以上配置,创建 ejb项目成功.



  • 相关阅读:
    Logstash配置文件介绍
    ElasticSearch搜索介绍四
    ElasticSearch文档操作介绍三
    ElasticSearch集群介绍二
    ElasticSearch入门介绍一
    Curl中的参数知多少
    sed命令使用介绍(转载)
    实例方法、类方法、静态方法
    函数概述,参数,可变参数,关键字参数,组合参数,递归函数
    startswith()函数与endswith()函数判断文件的开头和结尾
  • 原文地址:https://www.cnblogs.com/jifsu/p/2203082.html
Copyright © 2020-2023  润新知