docker compose: spring boot connection to mysql database refused

后端 未结 1 1277
温柔的废话
温柔的废话 2021-01-13 08:16

I\'m pretty new to Docker and I need to startup my Angular/SpringBoot/MySQL project with docker-compose on the docker toolbox. I copied a docker yml file into my project whi

1条回答
  •  粉色の甜心
    2021-01-13 08:47

    you need to change your connecion like this:

    jdbc:mysql://database:3306/db_example
    

    and add this to your docker-compose under springapi service:

    links:
       - database
    

    on the other hand you may use wait-for-it.sh to check if DB is up by add a command section under springapi service:

    command: ["path/to/wait-for-it.sh", "database:3306", "-t", "6000", "--", "YOUR ACTUAL COMMAND"]
    

    0 讨论(0)
提交回复
热议问题