I have implemented Docker into my spring boot aplication, in order to use mysql container I need to change my database url. Now when devoloping my application I use localhost:3306
and when creating my docker image I need to use my-mysql:3306
. This seams a bit tedious, what does people do after implementing docker? Thank you.
application.properties:
#Config for MySQL DB
#spring.datasource.url=jdbc:mysql://localhost:3306/caterest
spring.datasource.url=jdbc:mysql://my-mysql:3306/caterest
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database=mysql
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect