gpt4 book ai didi

java - 如何强制javamelody监控jdbc?

转载 作者:行者123 更新时间:2023-11-30 10:58:19 25 4
gpt4 key购买 nike

我尝试在我的应用程序中使用 java melody。

我做了以下操作:

  1. 添加了 maven 依赖:

  2. 添加过滤器:

    web.xml:

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>javamelody</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
<init-param>
<param-name>monitoring-path</param-name>
<param-value>/admin/monitoring</param-value>
</init-param>
</filter>

session 工厂配置如下所示:

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation">
<value>classpath:hibernate-test.cfg.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.driver_class">net.bull.javamelody.JdbcDriver</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hbm2ddl.auto">create-drop</prop>
</props>
</property>
</bean>

根据 IDE highliting - 这一行

<prop key="hibernate.connection.driver_class">net.bull.javamelody.JdbcDriver</prop>

错了。

在菜单中我没有看到关于 jdbc 的信息:

enter image description here

如何解释java melody监控jdbc?

最佳答案

您还需要设置 hibernate.connection.driver 属性。例如对于 Oracle:

<props>
<prop key="hibernate.connection.driver_class">net.bull.javamelody.JdbcDriver</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.connection.driver">oracle.jdbc.OracleDriver</prop>
</props>

关于java - 如何强制javamelody监控jdbc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32311425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com