The remote Spring Boot application is still connecting to my local mysql
I am working with Angular 4, Spring Boot and Mysql. Local, everything works fine. I am trying to deploy to a remote server, Centos 7. Everything works fine except that when I access my site, it pulls data from my local database, not from the mysql database located on the remote server.
I tried on another computer and the result is the same, it takes data from the local computer!
Here is my Spring boot.properties boot file:
server.port = 8081
spring.datasource.url=jdbc:mysql://localhost:3306/mydb?autoReconnect=true&useSSL=false
spring.datasource.username=username
spring.datasource.password=password
netstat -tln
on a remote server (only useful fields):
Proto Recv-Q Send-Q local address remote address State
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp6 0 0 :::8081 :::* LISTEN
Mysql databases have exactly the same structure and the same username / password.
- UPDATE -
Thanks for the suggestions, I have finally resolved this issue. It came from the relationship between Angular and Spring, not Spring and Mysql.
The Springboot instance was running on my local machine and the remote Angular was connected to it. In the Angular config file I replaced apiUrl=localhost:8081
with apiUrl=<my remote IP>:8081
, deploy again, I opened port 8081 (Springboot port) to everyone and now it works well.
But honestly, I don't like this method because my Springboot application is available to everyone, whereas it should only be available to an Angular application. If anyone has a solution, this question is still open. Thanks to
source to share