SpringBoot application failing to start with error: Failed to bind properties under 'server.port' to java.lang.Integer
I have tried to change the default port in my SpringBoot application from 8080 to 8888 by adding the server.port
property to my SpringBoot's application.properrties
file.
After the change, I am seeing the following exception while starting
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)
2019-07-04 23:29:17.980 INFO 4925 --- [ main] com.oc.springsample.Start : Starting Start on MacBook-Pro-6.local with PID 4925 (/springsample/target/classes started by foo in /springsample)
2019-07-04 23:29:17.983 INFO 4925 --- [ main] com.oc.springsample.Start : No active profile set, falling back to default profiles: default
2019-07-04 23:29:18.560 WARN 4925 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'servletWebServerFactoryCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class]: Unsatisfied dependency expressed through method 'servletWebServerFactoryCustomizer' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server.port' to java.lang.Integer
2019-07-04 23:29:18.568 INFO 4925 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-04 23:29:18.571 ERROR 4925 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'server.port' to java.lang.Integer:
Property: server.port
Value: 8888 // comments
Origin: class path resource [application.properties]:1:15
Reason: failed to convert java.lang.String to java.lang.Integer
Action:
Update your application's configuration
Following is the content in my application.properties
file
server.port = 8888 // changed port to 8888
1 Answer
5 years ago by Eleven
Single line comments start with hash (#
) in properties files. Change your configuration to the following
server.port = 8888 # changed port to 8888
5 years ago by Karthik Divi