spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://아이피:3306/데이터베이스?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true
spring.datasource.username=아이디
spring.datasource.password=비밀번호
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
@Entity
@Getter
@Setter
public class UserEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String username;
private String password;
private String role;
}
public interface UserRepository extends JpaRepository<UserEntity, Integer> {
// UserRepository 만드는 이유 ?
// 데이터베이스에서 UserEntity 테이블을 쉽게 다룰 수 있도록 도와주는 역할
// Spring Data JPA를 사용하면, SQL을 직접 작성하지 않아도 자동으로 데이터베이스 작업을 처리할수 있어
// JpaRepository를 통해 자동으로 CRUD 메서드를 제공해줌
// save(UserEntity user), findById(Integer id), findAll(), delete(UserEntity user) 이런 메서드들!
}
spring.jpa.hibernate.ddl-auto=create
실행하고 나서는 none으로 다시 바꿔야 한다!!
안바꾸면 실행할때 마다 기존 테이블 삭제 후 새로 생성됨