Reputation: 459
Hello i have an issue after i have added spring mail to my application.These are the app.propreties where the issue is.
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.auth=true
server.port=${PORT}
this is how i am binding it in the EmailConfig class
@Value("${spring.mail.port}")
private int port;
also this is the mail i am using
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
Every time i start the app i receive this error:
Description:
Failed to bind properties under 'server.port' to java.lang.Integer:
Property: server.port
Value: ${PORT}
Origin: class path resource [application.properties]:20:13
Reason: failed to convert java.lang.String to java.lang.Integer
Action:
Update your application's configuration
For some reason it seems that i cannot make requests on basic 8080 port.So i have modified the server.port to this server.port=${PORT:9191}
and it works but i get some requests issue with some of my pages for some reason.
Thing is , i have this same configuration on another application and it works without me having to modify the port to a different number.Why is this happening? i would like to remain on standard port.
Any help would be greatly appreciated !
Upvotes: 0
Views: 1729
Reputation: 51
app.properties
have server.port
property while in the code you try to access ${spring.mail.port}
which is empty.
Upvotes: 1
Reputation: 1670
If you want to remain on standard port, remove the line server.port from your application.properties (so it runs on 8080).
server.port
- used to configure the application to run in different port other than standard port.
spring.mail.port
- used to configure smtp server port. If your SMTP server is using standard port, you don't need to configure this property.
The other application that has the same configuration would have the PORT value set in either environment variables or system properties. It's not possible to run the application without assigning any value to PORT variable as it is a configuration parameter.
Upvotes: 1