JavaMelody brakes Spring Boot tests

1.4k Views Asked by At

The application is developed on Spring Boot 2.0.1. I include the next dependency to be able to use JavaMelody -

dependency("net.bull.javamelody:javamelody-spring-boot-starter:1.72.0")

JavaMelody configuration:

javamelody:
  advisor-auto-proxy-creator-enabled: false
  init-parameters:
    url-exclude-pattern: (/webjars/.*|/css/.*|/images/.*|/fonts/.*|/js/.*)

As a result I have a performance monitoring system and completely broken integration tests (JUnit version is 5).

The exception message is

the configured DataSource [com.sun.proxy.$Proxy128] (named '') is not the one associated with transaction manager [org.springframework.orm.jpa.JpaTransactionManager] (named '').

It can be fixed by removing javamelody dependency or by disabling javamelody in config file of the application.

Does somebody know the cause of the issue? Doesn't it create some unobvious bugs out of tests' scope?

2

There are 2 best solutions below

0
On BEST ANSWER

I faced the same issue. I found a solution. I checked the Java melody jar file and they have a spring.factories in there. I think this might be messing around with the configurations.

In the application-test.properties I added this:

spring.autoconfigure.exclude=net.bull.javamelody.JavaMelodyAutoConfiguration

and it seems to work.

0
On

add

spring.autoconfigure.exclude=net.bull.javamelody.JavaMelodyAutoConfiguration

in application.properties can help.