Could not resolve placeholder in string value
In your configuration you have 2 PropertySourcesPlaceholderConfigurer
instances.
applicationContext.xml
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="environment">
<bean class="org.springframework.web.context.support.StandardServletEnvironment"/>
</property>
</bean>
infraContext.xml
<context:property-placeholder location="classpath:context-core.properties"/>
By default a PlaceholderConfigurer
is going to fail-fast, so if a placeholder cannot be resolved it will throw an exception. The instance from the applicationContext.xml
file has no properties and as such will fail on all placeholders.
Solution: Remove the one from applicationContext.xml as it doesn't add anything it only breaks things.
I got same error in my Micro-service, whenever you declare @Value annotation in program i.e @Value("${project.api.key}")
make sure that your application.properties file with same values should not be blank project.api.key= add some values
MostIMP :otherwise it will throw error "Error creating bean with name 'ServiceFTP': Injection of autowired dependencies"
You can also try default values. spring-value-annotation
Default values can be provided for properties that might not be defined. In this example the value “some default” will be injected:
@Value("${unknown.param:some default}")
private String someDefault;
If the same property is defined as a system property and in the properties file, then the system property would be applied.
I had the same problem, resolved it by adding
<filtering>true</filtering>
in pom.xml :
before (didn't work):
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
after(it worked):
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
After that you just run mvn clean install and deploy application.