Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error during Maven Build of a Spring Boot Application

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading