Skip to content
Advertisement

In which database JpaRepository uses by default?

When we using methods that come from JpaRepository like save, in which database spring boot use? and how can we change the default database if necessary?

@Repository
  
// Interface
public interface FooRepository
    extends JpaRepository<Department, Long> {
}

Advertisement

Answer

It uses the database which you have configured in your properties file. You can change the database using the following properties(MySQL example):

spring.datasource.url=jdbc:mysql://localhost:3306/todo_example
spring.datasource.username=todouser
spring.datasource.password=YOUR_PASSWORD
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement