I have 2 spring microservice Applications and want them to access the same DB. But both Applications create a different databases when i run them. The Application.yml files:
Service 1:
server.port: 8002
logging:
level:
org:
springframework:
jdbc:
core:
DEBUG
spring:
application:
name: movie
datasource:
url: jdbc:h2:mem:movie_service
driver-class-name: org.h2.Driver
h2:
console:
enabled: true
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8001/eureka}
registryFetchIntervalSeconds: 1
instance:
leaseRenewalIntervalInSeconds: 1
#preferIpAddress: true
eureka.instance.prefer-ip-address: false
Service 2:
server.port: 8003
spring:
application.name: client
datasource:
url: jdbc:h2:mem:movie_service
driver-class-name: org.h2.Driver
h2:
console:
enabled: true
logging:
level:
org:
springframework:
jdbc:
core:
DEBUG
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8001/eureka}
registryFetchIntervalSeconds: 1
instance:
leaseRenewalIntervalInSeconds: 1
#preferIpAddress: true
eureka.instance.prefer-ip-address: false
I thought by providing the same URL, one service will create the DB and the other one will just use it.