我可以在standalone.xml中配置MySQL數據源,並且工作正常。但我想使用@DataSourceDefinition
註釋來配置數據源。在JBoss AS7中使用@DataSourceDefinition配置MySQL數據源
如何在JBoss AS7中使用@DataSourceDefinition配置MySQL數據源?
我已經嘗試是:
@DataSourceDefinition(
className = "com.mysql.jdbc.Driver",
name = "java:global/jdbc/MyDS",
serverName="localhost",
portNumber=3306,
user = "root",
password = "admin",
databaseName = "test"
)
@Startup
public class DBConfig {
}
本
的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="javaee6-app" transaction-type="JTA">
<jta-data-source>java:global/jdbc/MyDS</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
我在WEB-INF/lib
MySQL的連接器jar文件。
但是當我部署我得到這個錯誤的應用程序:
(DeploymentScanner-threads - 2) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"javaee6-app.war#javaee6-app\"jboss.naming.context.java.global.jdbc.MyDSMissing[jboss.persistenceunit.\"javaee6-app.war#javaee6-app\"jboss.naming.context.java.global.jdbc.MyDS]"]}}}
我已經說過,我能在standalone.xml配置數據源。我正在尋找基於@DataSourceDefinition的配置。 – 2013-02-27 05:47:01
您是否在Jboss模塊中配置了Mysql連接器Jar? – 2013-02-27 05:53:53