Petteri H
Petteri H

Reputation: 12222

Spring 3 @value annotation with maven profile properties

I have a bunch of properties defined in pom.xml for different profiles. I would like to use @value annotation to inject the property values. It is enough to get the values set at build time.

What kind of options I have with this @value annotation? Do I have to have a separate property file or can I utilize applicationContext.xml?

Upvotes: 1

Views: 2236

Answers (2)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298898

What I'd do is use the properties maven plugin to write the project properties to a file and then reference that file from Spring via the PropertyPlaceHolderConfigurer mechanism

Upvotes: 5

kan
kan

Reputation: 28951

The Maven filtering works as a simple textual substitution, it doesn't know anything about spring and annotations. Not sure which way is better for you, if you describe your problem (but not one of yours possible solutions), I could try to suggest more constructive solution.

Upvotes: 1

Related Questions