eclipse-ee4j / eclipse-ee4j/jersey
@Value members not populated without component-scan
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
When using the jersey-spring3 module, the members of a class that is annotated with @Value isn't beeing populated, but @Autowired are.
Here is an example of the behaviour:
[https://github.com/alexanderkjall/jersey-jetty-interaction-example](https://github.com/alexanderkjall/jersey-jetty-interaction-example)
If
is added to applicationContext.xml then both fields are populated. Otherwise the field 'message' stays as null.
I guess that this is intended behavior, but it makes it harder for us to write unit-tests.
In our main code we have component-scan populated, but in our unit tests we need to controll the content of the spring context precisely, so there we don't have it.
We can work around this by have all annotation on setter methods, but that adds boilerplate code that would be nice to be without.
It would also be nice if this was documented somewhere, as I didn't manage to find any information about it online.
#### Affected Versions
[2.24]
Contributor guide
Research direction
Start with the linked jersey-jetty-interaction-example and its applicationContext.xml, reproducing the difference with and without the component-scan entry. Confirm whether jersey-spring3 intentionally requires component scanning for @Value processing, then document the behavior, the unit-test implication, and the supported workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100