I am having a sample spring boot application, with the main class annotated with @SpringBootApplication, and have a controller, few services, repository classes, etc. I have application.properties file with a PostgreSQL connection configuration as below
spring.application.name=my-application-name
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://${db-host}:5432/${db-name}
spring.datasource.username=${db-user}
spring.datasource.password=${db-pwd}
spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
spring.datasource.hikari.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.maximumPoolSize=${db-connection-pool}
I have required dependencies also in my pom.xml, like of spring-boot-starter-data-jpa, HikariCP, and my application is starting up as well.
The problem arises when I do Maven Build with goals: clean install. Don’t know why, during maven build, I’m getting failure because of the below reason:
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.hikari.maximum-pool-size' to int
Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [int] for value '${db-connection-pool}'; nested exception is java.lang.NumberFormatException: For input string: "${db-connection-pool}"
It seems somehow its treating the configurable value as a hardcoded string value. Can someone help in providing solution for this ?
>Solution :
It does that when you don’t provide values for the configuration parameters, so you need to provide that.
If you used spring-initializer to set up the project, it will have generated a test, which verifies that your application context loads. That test is probably what is failing. If you don’t need it, you can also just skip running tests as part of your maven build.