Questions tagged [property-placeholder]
77 questions
86
votes
10 answers
@Value annotation type casting to Integer from String
I'm trying to cast the output of a value to an integer:
@Value("${api.orders.pingFrequency}")
private Integer pingFrequency;
The above throws the error
org.springframework.beans.TypeMismatchException:
Failed to convert value of type…

Ben
- 60,438
- 111
- 314
- 488
43
votes
6 answers
Spring @Value TypeMismatchException:Failed to convert value of type 'java.lang.String' to required type 'java.lang.Double'
I want to use the @Value annotation to inject a Double property such as:
@Service
public class MyService {
@Value("${item.priceFactor}")
private Double priceFactor = 0.1;
// ...
and using Spring property placeholder (Properties…

guilhebl
- 8,330
- 10
- 47
- 66
7
votes
6 answers
Interface Annotation does not accept application.properties value
I have developed a simple Annotation Interface
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomAnnotation {
String foo() default "foo";
}
then I test it annotating a Class
@CustomAnnotation
public class…

Federico Gatti
- 535
- 1
- 9
- 22
5
votes
1 answer
Loading String[] from properties file into origins field of @CrossOrigin using property placeholder expression
In my spring boot application I have the following controller
@RestController(value = "ProjectController")
@CrossOrigin(origins = {"${app.api.settings.cross-origin.urls}"})
public class ProjectController {
// some request mapping methods
}
The…

VIJAY KUMAR
- 51
- 6
5
votes
1 answer
Spring YAML profile configuration
I'm not sure if I well understand how Spring profiles works with yaml and properties files.
I was trying to misc those two types of configuration (the two file do not share any configuration) but i'm having problems when reading profiles from yaml…

Raffaele
- 461
- 1
- 7
- 20
4
votes
3 answers
How to resolve placeholder in properties file with values from another properties file in spring boot application
My spring boot application has below properties…

Anooj VB
- 41
- 1
- 1
- 5
4
votes
1 answer
Scope of and in hierarchical contexts
I have read:
Multiple component-scan
What is the difference between ApplicationContext and WebApplicationContext in Spring MVC?
@RequestMapping annotation not working if is in application context instead of dispatcher…

Jim Garrison
- 85,615
- 20
- 155
- 190
3
votes
0 answers
Is it possible to use placeholders ${} for a property KEY in a spring-boot application.yaml or properties
I'm wondering if it's possible to use the placeholder replacement not only in values but also for the key in a spring-boot application.yaml (or .properties).
For example:
openapi:
security:
- my-resource
- ${some.path.role-a}
…

Peter Müller
- 31
- 1
3
votes
1 answer
Accessing spring loaded properties in BeanDefinitionRegistryPostProcessor
How can I access properties loaded by in BeanDefinitionRegistryPostProcessor.postProcessBeanDefinitionRegistry.
I am unable to use fields annotated with @Value, as they do not seem to be initialized (their values are…

Mukund Jalan
- 1,145
- 20
- 39
3
votes
4 answers
How to replace placeholders within email template dynamically
Is there a good way to replace placeholders with dynamic data ?
I have tried loading a template and then replaced all {{PLACEHOLDER}}-tags, with data from the meta object, which is working.
But if I need to add more placeholders I have to do it in…

n3tx
- 429
- 2
- 10
- 23
3
votes
1 answer
Spring injecting property values without @Value annotation
We have been using Spring @Value annotation to inject the property values. We have a convention to name the property names to match the java fields they inject. This bring in unnecessary work that each of config bean's java fields needs to be…

singularity
- 1,057
- 2
- 10
- 20
3
votes
3 answers
Accessing properties in Karaf cfg file from java?
I am using cm:property-placeholder in blueprint to load config file:

Viktor D
- 136
- 1
- 7
2
votes
3 answers
LocalDate with Property place holder Spring
I am working with Spring Boot and property placeholders. I have a property file with the value : date.A=24/07/17.
I have a class and I am using the @Value annotation:
@Value("${date.A}")
private LocalDate dateA;
But I am getting the runtime error…

Chandresh Mishra
- 1,081
- 3
- 24
- 45
2
votes
1 answer
How to resolve placeholder when run Spring based application?
Collegues, i have java based Spring config:
@Configuration
@EnableTransactionManagement
@ComponentScan (basePackages = {"com.abc.dirint"})
@PropertySource("classpath:/settings/${env}/dir.properties")
@EnableScheduling
public class DirConfig {
…

May12
- 2,420
- 12
- 63
- 99
2
votes
1 answer
YAML anchor as a placeholders in URL string
Trying to use anchors in an additive way,
Following YAML code will not work but can explain what I want it to do
endpoint:
data.updates.index.name: &UPDATES-INDEX-NAME "data-updates"
meta.data.type.name: &DATA-TYPE-NAME "meta-data"
…

ViseSystems
- 36
- 2