Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Boa tarde, como usar o H2 Database nesse projeto do Bytebank?

Olá, gostaria de usar o H2 em vez de usar o MySQL. Como faço para usar o H2? Já instalei as dependências, mas o localhost não abre. Já configurei as application.properties também.

Application-test properties:

DATASOURCE

spring.datasource.driverClassName=org.h2.Driver spring.datasource.url=jdbc:h2:mem:testdb spring.datasource.username=root spring.datasource.password=root

H2 CLIENT

spring.h2.console.enabled=true spring.h2.console.path=/h2-console

JPA, SQL

spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.jpa.defer-datasource-initialization=true spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true

application.properties spring.profiles.active=test spring.jpa.open-in-view=true spring.mvc.format.date-time=yyyy-MM-dd HH:mm:ss security.basic.enabled=false

pom.xml

4.0.0 org.springframework.boot spring-boot-starter-parent 3.2.2 com.challengescrd challenge 0.0.1-SNAPSHOT challenge Demo project for Spring Boot <java.version>17</java.version> org.springframework.boot spring-boot-starter-web

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.3.0</version>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>3.2.2</version>
        </plugin>
    </plugins>
</build>
2 respostas

O console do H2 não abre ou a aplicação não abre ??

solução!

@Pedro Appel

Não abre a url http://localhost:8080/h2-console quando eu executo a aplicação! Obrigado.