Skip to content

Fix the ability to provide your own PebbleViewResolver#686

Merged
ebussieres merged 1 commit into
PebbleTemplates:masterfrom
nkavian:fix-pebble-view-resolver
Feb 3, 2025
Merged

Fix the ability to provide your own PebbleViewResolver#686
ebussieres merged 1 commit into
PebbleTemplates:masterfrom
nkavian:fix-pebble-view-resolver

Conversation

@nkavian

@nkavian nkavian commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

The documentation states we can provide our own PebbleViewResolver.

I'm upgrading from Pebble 3.1.0 to the latest 3.2.2, and my @Bean for my custom PebbleViewResolver breaks.

Starting the Spring Boot server (version 3.4.2) fails with:

The bean 'pebbleViewResolver', defined in class path resource [io/pebbletemplates/boot/autoconfigure/PebbleServletWebConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/myproject/extension/PebbleConfiguration.class] and overriding is disabled.

Pebble 3.1.0 had the correct implementation: @ConditionalOnMissingBean(name = "pebbleViewResolver")
Whereas 3.2.2 has @ConditionalOnMissingBean.

  • When the name is set, it allows the bean to come from anywhere.
  • When it is not set, it implies the provided bean must match the exact class return type of the method annotated, or be a derived class of the return type.

Workarounds?

  • I attempted to exclude the Configuration class PebbleServletWebConfiguration but that was not possible since the scope of that class is not public.
  • I could try to subclass the original PebbleViewResolver, but that has a different problem of forcing me to still use the built in PebbleView and not my custom View.

@ebussieres

Copy link
Copy Markdown
Member

Can you add a test case and apply the modification in reactive configuration too ?

@ebussieres ebussieres added this to the 3.2.3 milestone Feb 3, 2025
@nkavian nkavian force-pushed the fix-pebble-view-resolver branch from e2f96eb to 43eb4e2 Compare February 3, 2025 22:00
@nkavian

nkavian commented Feb 3, 2025

Copy link
Copy Markdown
Contributor Author
  • I've added tests and the change for Reactive.
  • I've verified the new tests by removing the annotation name = changes and seeing my tests fail.
  • Let me know if I need to refactor or change the code for style/content.

@nkavian nkavian force-pushed the fix-pebble-view-resolver branch from 43eb4e2 to 40213a6 Compare February 3, 2025 22:06
@ebussieres

Copy link
Copy Markdown
Member

Seems good to me ! Thx for your contribution. I' ll make a release later this week

@ebussieres ebussieres merged commit e18356f into PebbleTemplates:master Feb 3, 2025
@ebussieres

Copy link
Copy Markdown
Member

@nkavian The release has been made. It should be available soon

@nkavian nkavian deleted the fix-pebble-view-resolver branch February 5, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants