2013-05-06 47 views
0

我嘗試運行jboss-springmvc-webapp的示例項目,但未能配置數據源。錯誤數據源配置的彈簧示例

的錯誤是:

JBAS014775: New missing/unsatisfied dependencies: 
    service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.jboss/datasources/SpringQuickstartDS] 

我的persistence.xml是:

<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"> 
    <!-- If you are running in a production environment, add a managed 
    data source, this example data source is just for development and testing! --> 
    <!-- The datasource is deployed as WEB-INF/spring-quickstart-ds.xml, you 
    can find it in the source at src/main/webapp/WEB-INF/spring-quickstart-ds.xml --> 
    <jta-data-source>java:jboss/datasources/SpringQuickstartDS</jta-data-source> 
    <properties> 
    <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/spring-quickstart/persistence" /> 

    <property name="hibernate.hbm2ddl.auto" value="create-drop" /> 
    <property name="hibernate.show_sql" value="false" /> 
    </properties> 
</persistence-unit> 
</persistence> 

我datasource.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"> 
<!-- The datasource is bound into JNDI at this location. We reference 
    this in META-INF/persistence.xml --> 
<datasource jndi-name="java:jboss/datasources/SpringQuickstartDS" 
    pool-name="kitchensink-quickstart" enabled="true" 
    use-java-context="true"> 
<connection-url>jdbc:mysql://localhost:3306/testdb</connection-url> 
<driver>mysql</driver> 
    <security> 
    <user-name>root</user-name> 
    <password></password> 
    </security> 
</datasource> 
<drivers> 
    <driver name="h2" module="com.h2database.h2"> 
      <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> 
    </driver> 
      <driver name="mysql" module="com.mysql.jdbc"> 
       <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> 
      </driver> 
      <driver name="postgresql" module="org.postgresql.jdbc"> 
       <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
      </driver> 
     </drivers> 
</datasources> 
+0

也可以通過https://zorq.net/b/2011/07/12/adding-a-mysql-datasource-to-jboss-as-7/解決 – user504909 2013-05-06 22:43:40

回答

0

如果您使用的jboss-用SpringMVC-web應用architype,那麼它應該配置爲使用H2作爲數據源。我會首先回到該配置以確認它的工作原理。

然後,當你知道其他所有工作正常時,你可以設置一個MySQL數據源。有兩件事你需要知道。您一次只能指向一個數據源,因此您必須從上述文件中刪除其他數據源。它只能擁有MySQL信息(如果這是你使用的數據源)。其次,您需要確保您有要使用的數據庫的JDBC驅動程序。

每個版本的JBoss都有很好的文檔來設置它。你使用的是什麼版本的JBoss,我會發布文檔頁面?