-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Boot not working well with the new ResourceTransformer in Spring 4.1 #2360
Comments
/cc @bclozel |
@bclozel Do you think this an auto-configure problem or something that needs to change in Spring Framework? |
Hi @csavory I'm not sure I understand what's happening here. A few questions:
|
#1 - As far as I know, it's only related in that I was working on the ResourceTransformer integration this week and I created two issues in Spring Jira and one on the Spring Boot Github. #2 - I think I narrowed down the problem to Regarding #3, I think we could fix it two ways. Allow a priority for the |
@bclozel this could be related to https://jira.spring.io/browse/SPR-12630 |
I've opened https://jira.spring.io/browse/SPR-12647. Would that address your concerns here? |
@rstoyanchev, yes I think it would. As long as the ResouceHandler created by spring boot was ordered later in the list. |
@bclozel I'm trying to do some planning on our end. Do you have an anticipated milestone for this issue? |
@csavory This should be fixed in Spring Framework 4.1.5 and 4.2.0, see SPR-12647 for more details. I'll close this issue as it is confirmed to be a Framework issue; we'll open a new PR/issue against Boot if some changes are necessary. |
#2413 is tracking Boot's upgrade to Spring Framework 4.1.5 |
@bclozel thanks for all the fixes! We were finally able to upgrade to 1.2.2 and bring these changes in. |
Recently I introduced the new ResourceTransformer into our application for JS and CSS files. In my
WebConfig
I overrode theaddResourceHandlers
method. and added the following code:I added the
ResourceUrlEncodingFilter
as it says to do in the Spring 4.1 docs. Then when I tested my app I realized that the CSS files were being versioned, but the JS files were not being versioned. After a lot of debugging, I realized that the problem was inResourceUrlEncodingFilter.getForLookupPath
. It loops through all the handler mappings and uses the first one that matches with AntMatcher. My CSS links were being matched to my mapping that I added in myWebConfig
, but my JS links were always getting picked up by another mapping ("/") that did not include a version transformer. I finally tracked this mapping to the one that was added inWebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter.addResourceHandlers
. This was a huge pain since theResourceHandlerRegistry
API does not allow you to remove existing handlers, but only add new ones. I didn't want a to overwrite "/" since I didn't want all my links transformed. The only temporary solution I could come up with was to make myWebConfig
extendWebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter
so thatWebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter.addResourceHandlers
would not get called. Then I added anotherResourceHandler
to myaddResourceHandlers
for the static resources I did not want versioned.I don't think this is a good long term solution for us, but it works for the mean time.
The text was updated successfully, but these errors were encountered: