编程语言
首页 > 编程语言> > java-缺少/不可用依赖项的服务

java-缺少/不可用依赖项的服务

作者:互联网

知道为什么我会收到此错误:

JBAS014775:    New missing/unsatisfied dependencies:
  service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.jboss/datasources/UserDS] 
ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) `{"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.data-source.jboss/datasources/UserDSjboss.jdbc-driver.com_mysql_jdbcMissing[jboss.data-source.jboss/datasources/UserDSjboss.jdbc-driver.com_mysql_jdbc]"]}}}`

persistence.xml中

<?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0"
       xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
            http://java.sun.com/xml/ns/persistence
            http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
       <persistence-unit name="primary">
          <jta-data-source>java:jboss/datasources/UserDS</jta-data-source>
          <properties>
             <!-- Properties for Hibernate -->
             <property name="hibernate.hbm2ddl.auto" value="create-drop" />
             <property name="hibernate.show_sql" value="true" />
          </properties>
       </persistence-unit>
    </persistence>

mydatasource-ds.xml中

    <?xml version="1.0" encoding="UTF-8"?>
            <datasources xmlns="http://www.jboss.org/ironjacamar/schema"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
                <datasource jndi-name="java:jboss/datasources/UserDS" pool-name="kitchensink-quickstart" 
                    enabled="true" use-java-context="true">
                    <!-- jdbc:h2:mem:kitchensink-quickstart;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 -->
                    <connection-url>
                        jdbc:mysql://localhost:3306/test
                    </connection-url>
                    <driver>mysql</driver>
                    <security>
                        <user-name>root</user-name>
                        <password>root</password>
                    </security>
                </datasource>
            </datasources>

module.xml

<module xmlns="urn:jboss:module:1.0" name="com.mysql">
      <resources>
        <resource-root path="mysql-connector-java-5.1.22.jar"/>
      </resources>
      <dependencies>
        <module name="javax.api"/>
      </dependencies>
    </module>

解决方法:

错误的原因是您缺少依赖java:jboss / datasources / UserDS.
使用Jboss 7.x,可以将这些数据源直接添加到您发现的应用服务器配置中.

独立配置和域配置之间的区别在于,独立配置仅针对具有该配置的一台应用服务器而设计.如果仔细查看domain.xml,您将看到几种应用程序服务器配置(也称为配置文件).这些将与在standalone / conf *目录下找到的独立,独立完整,独立ha,独立完整ha配置文件相似.以域模式运行允许您从中央位置(即域控制器)控制在该域上运行的许多不同的服务器实例. (如果您已配置ha,则包括集群的节点)

这与您的原始问题密切相关,因为域控制器具有将数据源配置优雅地共享到其所有节点的能力.

标签:java,mysql,persistence,ejb-3-0
来源: https://codeday.me/bug/20191010/1888308.html