Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Duvidas sobre configuração com MariaDB

Boa Tarde estou utilizando o MariaDB conforme o curso porem quando eu rodava o SpringDateApplication ele fechava a conexão com o bd, conforme fui vendo no fórum testei colocar as dependências do spring-boot-starter-data-jpa e do Spring-boot-starter-web, porem agora ele me aparece uma linha dizendo que inicializou o tomcat eu gostaria de saber se é normal, pois no vídeo essa linha não aparece ou se eu estou fazendo algo errado.

Segue código do console:


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.4.4)

2021-04-08 12:13:33.104  INFO 1924 --- [           main] b.c.a.spring.date.SpringDateApplication  : Starting SpringDateApplication using Java 14.0.1 on Carlos with PID 1924 (C:\Users\User\Desktop\Alura\Spring Boot Framework\Spring Data JPA\spring-date\target\classes started by User in C:\Users\User\Desktop\Alura\Spring Boot Framework\Spring Data JPA\spring-date)
2021-04-08 12:13:33.107  INFO 1924 --- [           main] b.c.a.spring.date.SpringDateApplication  : No active profile set, falling back to default profiles: default
2021-04-08 12:13:34.291  INFO 1924 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-04-08 12:13:34.329  INFO 1924 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 19 ms. Found 0 JPA repository interfaces.
2021-04-08 12:13:35.173  INFO 1924 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-04-08 12:13:35.191  INFO 1924 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-04-08 12:13:35.191  INFO 1924 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.44]
2021-04-08 12:13:35.363  INFO 1924 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-04-08 12:13:35.363  INFO 1924 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2175 ms
2021-04-08 12:13:35.669  INFO 1924 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-04-08 12:13:35.721  INFO 1924 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.29.Final
2021-04-08 12:13:35.978  INFO 1924 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-04-08 12:13:36.141  INFO 1924 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-04-08 12:13:36.233  INFO 1924 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-04-08 12:13:36.267  INFO 1924 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MariaDBDialect
2021-04-08 12:13:36.580  INFO 1924 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-04-08 12:13:36.600  INFO 1924 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-04-08 12:13:36.673  WARN 1924 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-04-08 12:13:36.869  INFO 1924 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-04-08 12:13:37.185  INFO 1924 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-04-08 12:13:37.198  INFO 1924 --- [           main] b.c.a.spring.date.SpringDateApplication  : Started SpringDateApplication in 4.678 seconds (JVM running for 5.277)
1 resposta
solução!

Olá João, tudo bem com você?

Como não estamos manipulando o banco ainda, tudo bem o banco iniciar e fechar logo em seguida, é esperado que isso aconteça:

HikariPool-1 - Shutdown initiated...
HikariPool-1 - Shutdown completed.

Dentre as dependências que você citou, nós só precisamos da spring-boot-starter-data-jpa para termos acesso ao Spring Data JPA. Já a dependência spring-boot-starter-web - que está inicializando o Tomcat, não é necessária no momento, então sinta-se livre para removê-la do pom.xml. No final, só tenha certeza que você tem as dependências do Spring Data JPA e do MariaDB:

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

<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
</dependency>

Bom, acho que é só isso. Qualquer dúvida é só avisar! ;)

Forte abraço e bons estudos!!