-
[Data] gradle+mysql+jpaSpringboot 2019. 12. 5. 11:37
[1] Create the application.properties File
spring.jpa.hibernate.ddl-auto=update
#none: No change is made to the database structure. (good choice)
#update: Hibernate changes the database according to the given entity structures.
#create: Creates the database every time but does not drop it on close.
#create-drop: Creates the database and drops it when SessionFactory closes.* Mysql default : none
* H2 and etc... : create-drop
<!> You must begin with either create or update, because you do not yet have the database structure.
After the first run, you can switch it to update or none
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword[2] Create the @Entity Model
Hibernate automatically translates the entity into a table.
[3] Create the Repository
Spring automatically implements this repository interface in a bean that has the same name
ex) name change crudRepository -> userRepository
[4] Create a Controller
'Springboot' 카테고리의 다른 글
[Batch] (0) 2020.06.15 [H2] (0) 2019.12.20 [REST] (0) 2019.12.06 curl Unexpected character (''' (code 39)) (0) 2019.12.06 [Lombok] 이클립스 적용안됨 (0) 2019.10.24