我試過兩種方法將p6Spy功能添加到彈簧使用的項目中。無法實現p6Spy
路線我,
http://templth.blogspot.com.tr/2004/11/integrate-p6spy-with-spring.html 我改變了我的司機與com.p6spy.engine.spy.P6SpyDriver
和realdriver realdriver=com.ibm.db2.jcc.DB2Driver
加入spy.properties
文件。
但不知何故我的真實驅動程序正在註冊p6spy 驅動程序com.ibm.db2.jcc.DB2Driver是spy.properties中的真實驅動程序,但它已在p6spy之前加載。 p6spy不會包裝這些連接。要麼阻止驅動程序加載,要麼嘗試在spy.properties中將'deregisterdrivers'設置爲true
使用:p6spy:
前綴對我不起作用。它說無法建立與該網址的連接。
所以,我選擇在屬性文件中設置這個deregisterdrivers=true
。 這次我在日誌文件中獲取sql,但無法執行sqls。我能夠在另一個sql編輯器中執行sql。這似乎是真正的聯繫,並有一個虛擬的聯繫。
Route II, 使用春天。所以我試過這種方法。將數據源明確賦予p6Spy。但這次,春天抱怨多個java.sql.DataSource實例。 com.firm.BasicDataFill
和com.p6spy.engine.spy.P6DataSource
都實現了DataSource。春天不能獲得一個單身人士。
http://templth.blogspot.com.tr/2004/11/integrate-p6spy-with-spring.html
<bean id="dataSource" lazy-init="true"
class="com.firm.BasicDataFill">
<property name="driverClassName" value="${database.connection.driver_class}" />
<property name="username" value="${database.connection.username}" />
<property name="password" value="${database.connection.password}" />
<property name="url" value="${database.connection.url}" />
...
<property name="accessToUnderlyingConnectionAllowed" value="true" />
</bean>
<!-- bean id="myDataSource" class="com.p6spy.engine.spy.P6DataSource">
<constructor-arg>
<ref local="dataSource"/>
</constructor-arg>
</bean-->
最後,我發現P6SPY V1.3和2.4.1設置而異。你對基於彈簧的應用程序有任何建議嗎?
也許這將有助於某人: http://stackoverflow.com/a/39272477/4952633 –