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

Tabela Cargos nao foi criada automaticamente

Após inicializar o Spring, os logs que aparecem no console, não indicam algum problema:

2021-01-30 23:40:11.557  INFO 87624 --- [           main] b.c.s.s.data.SpringBootMySqlApplication  : Starting SpringBootMySqlApplication using Java 1.8.0_231 on DESKTOP-R17JKRE with PID 87624 (C:\Users\caiom\estudo\spring-data\spring-data\target\classes started by statix in C:\Users\caiom\estudo\spring-data\spring-data)
2021-01-30 23:40:11.560  INFO 87624 --- [           main] b.c.s.s.data.SpringBootMySqlApplication  : No active profile set, falling back to default profiles: default
2021-01-30 23:40:12.209  INFO 87624 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-01-30 23:40:12.221  INFO 87624 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 4 ms. Found 0 JPA repository interfaces.
2021-01-30 23:40:12.830  INFO 87624 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-01-30 23:40:12.839  INFO 87624 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-01-30 23:40:12.839  INFO 87624 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-01-30 23:40:12.921  INFO 87624 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-01-30 23:40:12.921  INFO 87624 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1308 ms
2021-01-30 23:40:13.105  INFO 87624 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-01-30 23:40:13.152  INFO 87624 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.27.Final
2021-01-30 23:40:13.269  INFO 87624 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-01-30 23:40:13.398  INFO 87624 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-01-30 23:40:13.462  INFO 87624 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-01-30 23:40:13.487  INFO 87624 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MariaDBDialect
2021-01-30 23:40:13.744  INFO 87624 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-01-30 23:40:13.754  INFO 87624 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-01-30 23:40:13.807  WARN 87624 --- [           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-01-30 23:40:13.997  INFO 87624 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-30 23:40:14.267  INFO 87624 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-01-30 23:40:14.274  INFO 87624 --- [           main] b.c.s.s.data.SpringBootMySqlApplication  : Started SpringBootMySqlApplication in 3.016 seconds (JVM running for 3.352)

Minha Classe Cargo ->

package br.com.statix.orm;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "cargos")
public class Cargo {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    private String descricao;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }
}

a tabela não foi criada automaticamente como na aula, alguma configuração que possa está errada?

1 resposta
solução!

Resolução:

a classe que será mapeada, precisa está em um um sub-package onde o a classe main está rodando, meu package era: br.com.statix.orm, mudando para br.com.statix.spring.data.orm, funcionou perfeitamente, isso porque minha classe main do spring está rodando no package: br.com.statix.spring.data,

Tem outras maneiras de fazer funcionar, o que acontece é que você precisa especificar para o Framework que ele ira carregar aquela entidade, nesse caso o @EnableAutoConfiguration está apenas para os sub-packages e nao para todos outros, pelo que li na documentação e resolução de erros.

link que me ajudou: https://stackoverflow.com/questions/26881739/unable-to-get-spring-boot-to-automatically-create-database-schema