spring-hateoas icon indicating copy to clipboard operation
spring-hateoas copied to clipboard

Simple solution to provide the environment.

Open lyca opened this issue 4 years ago • 9 comments

  • should work in all Spring Boot applications
  • i am unsure about potential class loading issues around the static EnvironmentHolder in the StaticEnvironmentProvider (it is working in my deployments without issues so far)
  • the solution provided in #1375 for #361 seems to be overengineered
  • fixes #1406

lyca avatar Dec 10 '20 19:12 lyca

I'm not sure I see the benefit of moving to this bean-based approach of getting the Environment compared to simply pulling it out of the WebApplicationContext if needed.

gregturn avatar Mar 15 '21 14:03 gregturn

I currently do not see any method, that simply returns the WebApplicationContext for this to work. The current implementation does not work in Spring Boot as pointed out on SO over here https://stackoverflow.com/questions/22167912/contextloader-getcurrentwebapplicationcontext-always-returns-null and in issue #1406 by @adriendengreville

lyca avatar Mar 15 '21 21:03 lyca

Hi guys, when it will be merged? Faced exactly the same problem in spring boot.

ShishkinDmitriy avatar Apr 28 '21 17:04 ShishkinDmitriy

Hi, is this ever to be merged? From reading https://github.com/spring-projects/spring-hateoas/pull/1328 I understood it was solved 2 years ago by @lyca and @odrotbohm stated its merged but for me its not working and can also not see those code changes in the latest source (using 2.6.9). Thanks for the clarification!

romanpierson avatar Nov 28 '22 21:11 romanpierson

They don't need to be in there, as the fix for #1328 is actually a better solution than what's been suggested here. Would you mind creating a ticket and leave a few details of what exactly doesn't work, ideally with an accompanying reproducer.

odrotbohm avatar Nov 29 '22 15:11 odrotbohm

Sure I created a small reproducer - thanks for reaching out and let me know if that's not the intended way of how this should be used and work.

https://github.com/romanpierson/spring-hateoas-reproducer

romanpierson avatar Nov 29 '22 18:11 romanpierson

They don't need to be in there, as the fix for #1328 is actually a better solution than what's been suggested here. Would you mind creating a ticket and leave a few details of what exactly doesn't work, ideally with an accompanying reproducer.

As lyca pointed out #1328 did not resolve the issue for spring boot apps, since ContextLoader.getCurrentWebApplicationContext() is null in this case. Therefore PropertyResolvingMappingDiscovery.resolveProperties does not resolve the properties contained in the mapping (verified on spring boot 3.1.5, spring-hateoas 2.1.2). Therefore I think this PR is justified.

ckdrunix avatar Nov 09 '23 16:11 ckdrunix

They don't need to be in there, as the fix for #1328 is actually a better solution than what's been suggested here. Would you mind creating a ticket and leave a few details of what exactly doesn't work, ideally with an accompanying reproducer.

As lyca pointed out #1328 did not resolve the issue for spring boot apps, since ContextLoader.getCurrentWebApplicationContext() is null in this case. Therefore PropertyResolvingMappingDiscovery.resolveProperties does not resolve the properties contained in the mapping (verified on spring boot 3.1.5, spring-hateoas 2.1.2). Therefore I think this PR is justified.

Completely correct... When will this fix be merged?

bcnapelinckx avatar Apr 23 '24 13:04 bcnapelinckx

Not sure what's the point of requesting a reproducer to be honest .......

romanpierson avatar Apr 24 '24 21:04 romanpierson