in my project there are 2 resource properties
1. application.properties
server.port=8002
spring.data.mongodb.host=
spring.data.mongodb.port=
spring.data.mongodb.database=
spring.data.mongodb.username=
spring.data.mongodb.password=
2. application-development.properties
server.port=8002
spring.data.mongodb.host=
spring.data.mongodb.port=
spring.data.mongodb.database=
spring.data.mongodb.username=
spring.data.mongodb.password=
spring.data.solr.host
this class uses the value properties of development
@Configuration
@EnableSolrRepositories(basePackages = {
"id.alfadigital.alfagift.service.product.v1.db.solr.repository",
"id.alfadigital.alfagift.service.product.v2.db.solr.repository"
})
public class SolrConfiguration {
@Value("${spring.data.solr.host}")
private String solrUrl;
@Bean
public SolrClient solrClient() {
return new HttpSolrClient.Builder(solrUrl).build();
}
@Bean
public SolrTemplate solrTemplate(SolrClient client) {
return new SolrTemplate(client);
}
}
I use application-development.properties as my project resoure
so I run the project with the following command :
mvn spring-boot:run -D spring.profiles.active=development
but an error is attached when I run the project
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'solrConfiguration':
Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException:
Could not resolve placeholder 'spring.data.solr.host' in value "${spring.data.solr.host}"
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.data.solr.host' in value "${spring.data.solr.host}"
I'm confused, where are my mistakes, and how should I do?