Beans implementing Thymeleaf's IDialect
interface are automatically registered by Spring Boot as dialects for Thymeleaf templates.
But this doesn't happen in WebMvcTests, where IDialect beans are not included. It seems to me that they belong to the web MVC layer, and should thus be added to the WebMvcTest slice.
The workaround is of course easy enough:
@Import(MyCustomDialect.class)
Comment From: wilkinsona
Thanks, @jnizet. This feels like a bug to me. It doesn't really make sense to include an auto-configuration while excluding user-provided beans that it would normally consume.
Comment From: sadath42
Hi @wilkinsona is this bug available to work , I would be interested to work on it.
Comment From: wilkinsona
@sadath42 Thanks for the offer. A contribution that fixes this would be much appreciated. Please let us know if you have any questions.
Comment From: sadath42
@wilkinsona No questions as if now. I am analyzing the bug if there any questions will let you know .
Comment From: wilkinsona
How's it going, @sadath42? It's been a while now. If you no longer have time to work on a fix, please just let us know and we can take care of it. Equally, please let us know if you have any questions.
Comment From: sadath42
Hi , Please assign it someone else.
Comment From: priiduneemre
Sorry for thread necromancy.
Is there a nice way to achieve the "old" behavior, i.e. exclude custom dialects from the @WebMvcTest
slice, specifically?
I suppose excludeFilters
is the only way?
EDIT: To clarify the usecase, suppose you have a bunch of @WebMvcTest
-s for REST controllers and then use Thymeleaf for templating in javax.mail
domain. Ideally, you would like to avoid dealing with the mail-related stuff (incl. dialects) in any old controller test.
Comment From: wilkinsona
Yes, an exclude filter would be the best way to filter out unwanted beans found via component scanning.