Dear p6spy contributors!
I’ve been trying for few days to integrate p6spy into spring boot application without any success.
Hope you can help me. As I already mentioned I have a spring boot application (v1.4.1) with hibernate (v4.3.11.FINAL), h2 memory database (v.1.4.192) and p6spy (v3.0.0).
My configuration files are given below.
application.yml
spring:
application:
name: persistence
datasource:
url: jdbc:p6spy:h2:mem:persistence;DB_CLOSE_DELAY=-1
username: sa
password:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver #org.h2.Driver
jpa:
database-platform: kz.dits.persistence.domain.util.FixedH2Dialect
database: H2
open-in-view: false
hibernate:
ddl-auto: create-drop
naming:
strategy: org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy
spy.properties
driverlist=org.h2.Driver
As I understood from docs such configurations should create spy.log file inside project directory. However I don’t see any log files.
I tried to override appender in spy.properties file
driverlist=org.h2.Driver
appender=com.p6spy.engine.spy.appender.StdoutLogger
But I don’t see sql parameters in sql queries. All I see are standard hibernate logs
Hibernate: insert into its_vehicle_group (created_by, created_date, last_modified_by, last_modified_date, code, coefficient, description, id) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select vehiclegro0_.id as id1_15_0_, vehiclegro0_.created_by as created_2_15_0_, vehiclegro0_.created_date as created_3_15_0_, vehiclegro0_.last_modified_by as last_mod4_15_0_, vehiclegro0_.last_modified_date as last_mod5_15_0_, vehiclegro0_.code as code6_15_0_, vehiclegro0_.coefficient as coeffici7_15_0_, vehiclegro0_.description as descript8_15_0_ from its_vehicle_group vehiclegro0_ where vehiclegro0_.id=?
I would appreciate any help.
Best regards,
Rustem Yessekeyev
P.S Sorry for my English. Not my first or second language
Sent from Mail for Windows 10
--
You received this message because you are subscribed to the Google Groups "p6spy users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to p6spy-users+unsubscribe@googlegroups.com.
To post to this group, send email to p6spy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/p6spy-users/58600ce3.879e190a.31dab.e8e3%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.
--
@Bean @Order(Ordered.HIGHEST_PRECEDENCE) BeanPostProcessor dataSourcePostProcessor() {
return new BeanPostProcessor() { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return wrapDataSource(bean); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; }
Object wrapDataSource(Object bean) { if (bean instanceof DataSource) { return new P6DataSource((DataSource) bean); } return bean; } }; }
To unsubscribe from this group and stop receiving emails from it, send an email to p6spy-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to p6spy-users+unsubscribe@googlegroups.com.
To post to this group, send email to p6spy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/p6spy-users/1daf6521-154c-4621-a50c-3ca7aff61032%40googlegroups.com.
Have you tried just wrapping the data source in your config instead of using a BPP? The example at https://stackoverflow.com/questions/14706029/usage-of-p6spy-with-datasource-in-spring-applicationcontext-xml is for XMl configuration but the same approach works for java config as well.
--
You received this message because you are subscribed to the Google Groups "p6spy users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to p6spy-users+unsubscribe@googlegroups.com.
To post to this group, send email to p6spy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/p6spy-users/f3f14c0b-3711-43ef-976c-6313b8768712%40googlegroups.com.
@Bean
BeanPostProcessor dataSourcePostProcessor() {
return new BeanPostProcessor() { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return wrapDataSource(bean);
}
Object wrapDataSource(Object bean) { if (bean instanceof DataSource) { return new P6DataSource((DataSource) bean); } return bean; } }; }
Oh, Spring Boot autoconfiguration is the reason for the BPP. That makes sense now. Is the code that you submitted in the prior message still correct for the BPP? If so, do you mind if we include it in our documentation (and perhaps in an autoconfig module)?
On Thu, Jul 27, 2017 at 5:37 AM, Jorg Heymans via p6spy users <p6spy-users+APn2wQdxifwsrkbPOZwiwzq_KCfC1Fy9rUGWdMFoF0e9SbFAgIA_@googlegroups.com> wrote:
In the end i traced it down to the fact that a bean was causing the datasource to be very-eagerly instantiated, before the BPP was known to the application context. Adding a depends-on from this application bean to the BPP made it work.--Thanks,Jorg
On Thursday, July 27, 2017 at 10:51:10 AM UTC+2, Jorg Heymans wrote:This turned out quite hard to do as well, with circular references all over the place. I suspect the datasource autoconfiguration is getting in the way but i don't have time to look into it further now.
The funny thing is that for another (much smaller) spring boot application, th BPP works fine and is invoked correctly very early when the application context is still initializing, so that all subsequent repository beans get the P6 datasource.Jorg
On Wednesday, July 26, 2017 at 11:48:00 PM UTC+2, Quinton McCombs wrote:Have you tried just wrapping the data source in your config instead of using a BPP? The example at https://stackoverflow.com/questions/14706029/usage-of-p6spy-with-datasource-in-spring-applicationcontext-xml is for XMl configuration but the same approach works for java config as well.
You received this message because you are subscribed to the Google Groups "p6spy users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to p6spy-users...@googlegroups.com.
To post to this group, send email to p6spy...@googlegroups.com.