In Spring Boot what tells the app to use a database? -


this question has answer here:

i've small spring boot project maven pulls

  • spring-boot-starter-data-jpa
  • spring-boot-starter-data-rest
  • h2

and others. don't have datasource references, have jparepository , userdetailsservice.

how, then, spring libraries deciding use hibernate (shows logged in console) and, guess, h2?

i looked @ stackoverflow conversation own console log has no "h2" or "database" log statements.

you should add "schema.sql" src/main/resource. must match entity classes. spring boot take care of rest. better write application.properties

spring.jpa.hibernate.ddl.auto=create-drop 

you can work mysql instead of h2. delete h2 dependency, add mysql connector dependency , add these application.properties

spring.datasource.url=jdbc:mysql://localhost/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.driver 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -