网站运行时,有时会把hibernate的查询语句显示在JSP页面上部

IM_Wulv 2017-03-15 09:18:39

网站部署后,有时候点开会出现上图的情况。
想问问各位有没有出现类似的情况,有什么原因可能导致上述情况呢?

log配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<property name="LOG_HOME" value="D:/xxx_logs"/>

<appender name="STOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] [%file : %line] - %msg%n</pattern>
</encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${LOG_HOME}/run.log</File>
<encoder>
<pattern>%d{HH:mm:ss.SSS} %level [%thread] [%file : %line] - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/run-%d{yyyyMMdd}.%i.zip</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
</appender>
<logger name="org.hibernate.engine.internal.StatisticalLoggingSessionEventListener" level="off"/>


<root level="error">
<appender-ref ref="STOUT"/>
<appender-ref ref="FILE"/>
</root>
</configuration>


Context配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:xcf="http://www.xmcares.com/schema/framework"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd" profile="">

<!--配置数据源-->
<!--<context:property-placeholder location="classpath:dbconfig.properties" />-->
<bean id="propertyConfigurer" class="com.xxxxxx.framework.database.DBPropertiesCrypter">
<property name="location" value="classpath:dbconfig.properties"/>
</bean>
<xxx:annotation-driven id="xxx-xxxx" dataSource-ref="dataSource"
entityManagerFactory-ref="entityManagerFactory"
message-basenames="classpath:i18n/message"/>

<xxx:serviceful-driven />

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="initialSize" value="10"/>
<property name="minIdle" value="10"/>
<property name="maxIdle" value="200"/>
</bean>

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan"
value="com.xxxxx.xxxxxx" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<!-- 默认数据库用户-->
<prop key="hibernate.default_schema">${schema.app}</prop>

<!-- 开启二级缓存 -->
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<!-- 启动"查询缓存"如果想缓存使用findall()、list()、Iterator()、createCriteria()、createQuery()等方法获得的数据结果集,必须配置此项-->
<prop key="hibernate.cache.use_query_cache">true</prop>
<!-- 二级缓存区域名的前缀 -->
<!--<prop name="hibernate.cache.region_prefix">test</prop>-->
<!-- 高速缓存提供程序(Hibernate4以后都封装到org.hibernate.cache.ehcache.EhCacheRegionFactory ) -->
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>

<!-- 指定缓存配置文件位置 -->
<!-- <prop name="hibernate.cache.provider_configuration_file_resource_path">
ehcache.xml
</prop> -->
<!-- 强制Hibernate以更人性化的格式将数据存入二级缓存 -->
<prop key="hibernate.cache.use_structured_entries">true</prop>
<!-- Hibernate将收集有助于性能调节的统计数据 -->
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.ejb.interceptor">com.xxxxx.framework.database.EntityInterceptor</prop>
</props>
</property>
</bean>

<!--事务-->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />

<jpa:repositories base-package="com.xxxxx.xxxxxx"
transaction-manager-ref="transactionManager" entity-manager-factory-ref="entityManagerFactory"/>
</beans>


hibernate 的输出配置:

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.show_sql=true

上面确实是设置成输出了,但是应该输出到控制台啊....而且控制台也确实有输出啊.

war包是eclipse默认导出的。
Tomcat 版本:apache-tomcat-7.0.59







...全文
194 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
快跑蜗牛哥 2017-03-17
  • 打赏
  • 举报
回复
是不是中jsp页面,有输出sql语句? jsp页面是不是有 <% out.print(sql); %> 这样的语句?
pxk8001 2017-03-17
  • 打赏
  • 举报
回复
hibernate.show_sql 是输出sql语句的,你把他的值改为false再看看。
能源恒观 2017-03-15
  • 打赏
  • 举报
回复
这个问题挺奇怪的,jsp页面代码能看看嘛
浮云若水 2017-03-15
  • 打赏
  • 举报
回复
你吧代码块try catch就不会出现了 这是因为你没try catch 导致后台报错 吧后端的异常信息回写到了页面

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧