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
Post a Comment