除了设置模块
JBOSS_HOME/modules/com/p6spy/main
添加p6spy.jar
和module.xml
说:
<module xmlns="urn:jboss:module:1.0" name="com.p6spy">
<resources>
<resource-root path="p6spy.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
编辑standalone-full.xml
并在datasources/drivers
下添加一个条目:
<driver name="p6spy" module="com.p6spy">
<xa-datasource-class>com.p6spy.engine.spy.P6SpyDriver</xa-datasource-class>
</driver>
在jboss-deployment-struct.xml
中添加模块依赖项:
<module name="com.p6spy"/>
用p6spy
替换数据源定义中的原始驱动程序,我仍然收到此错误:
Caused by: java.lang.Exception:
{"JBAS014771: Services with missing/unavailable dependencies" =>
["jboss.data-source.jboss/datasources/MyDsjboss.jdbc-driver.p6spyMissing
[jboss.data-source.jboss/datasources/MyDsjboss.jdbc-driver.p6spy]"
]}
最佳答案
这是一个相当老的问题,但我为了 future 的读者而回答。
您不需要 p6spy,JBoss AS 7 提供开箱即用的 spy 功能。需要两个步骤。
将以下内容放入您的standalone.xml 的日志记录部分:
<logger category="jboss.jdbc.spy"> <level name="DEBUG"/> </logger>
在数据源配置中添加 spy=”true” 属性,如下所示:
<datasource jndi-name="java:jboss/datasources/testDS" pool-name="test" enabled="true" use-java-context="true" spy="true"> <connection-url>jdbc:postgresql://localhost:5432/postgres</connection-url> <driver>postgresql</driver> <security> <user-name>postgres</user-name> <password>******</password> </security> </datasource>
就是这样。现在,您已将所有数据库通信记录在 server.log 中。 spy 日志实际上对我来说有点太冗长了,但你确实拥有所有信息。
关于java - 如何在 jBoss 7.x 上的 Arquillian 测试中设置 p6spy 驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12742881/