-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Bob Tiernay opened SPR-4447 and commented
Some great ideas about how to improve Spring's annotation based configuration is mentioned in the following article:
http://www.jroller.com/Solomon/entry/guice_and_spring_2_51
One of the stumbling blocks with a prodominantly annotation based configuration is the setup and injection of external configuration (the kind of stuff you want externalized in an XML file or a property file, such as connection information, file names, counts and Controller view names. Most of the time, those kinds of values are primitives). Typically, such configuration values come from properties files and are made available via variants of PropertyPlaceholderConfigurer. However, in such an environment this is difficult to achieve since Strings, Integers, etc are not considered component types (see http://jira.springframework.org/browse/SPR-3744).
One solution to this issue is what Solomon writes about:
An @Value annotation with property resolution... For example:
@Autowire public void setI(@Value("${i}") int i)
With a property file entry:
i=5
This seems very natural and seems to be the annotation configuration based version of Java Config's @ExternalValue (see http://www.thespringexperience.com/blog/rod_johnson/2007/11/spring_java_configuration_moving_ahead.html)
If this is a sensible approach, consider unifying the two annontations to be common.
Attachments:
- spring2.5-configuration.zip (17.52 kB)
3 votes, 7 watchers