개발 관련/어려웠던것들
h2 콘솔창 안보일때 설정
꽉 쥔 주먹속에 안경닦이
2023. 4. 21. 22:41
728x90
제목 그대로 h2콘솔창이 안보여서 왜 pom.xml파일에 의존성을 추가했는데 보이지 않을까? 찾다가
해결방법을 찾아서 올려봅니다.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
h2,devtools 의존성은 위와 같이 설정
application.properties 파일을 아래와 같이 추가해주세요.
spring.h2.console.enabled=true
그렇다면 뜨지 않았던 콘솔창을 확인해볼수 있습니다 ㅜㅜ
그리고 간단한 URL 설정도 바꿔볼게요.
spring.datasource.url=jdbc:h2:mem:test
이렇게하면 URL도 바꿀 수 있습니다.
추가 작성
추가로 Mysql연결코드도 알려드릴게요.
application.properties
# database init, supports mysql too
database=mysql
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic}
spring.datasource.username=${MYSQL_USER:petclinic}
spring.datasource.password=${MYSQL_PASS:petclinic}
# SQL is written to be idempotent so this is safe
spring.sql.init.mode=always
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
pom.xml
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
728x90