Estou tendo o seguinte problema em minha aplicação, não estou sabendo identificar o problema, aparentemente está tudo correto.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/GUILHERME.GONZALES/Desktop/backend-test-java/target/classes/data.sql]: INSERT INTO veiculo(marca, modelo, cor, placa, tipo) VALUES("VOLKSWAGEN","GOLF GTI","PRETO","ABC1D231","CARRO"); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "VEICULO" not found; SQL statement:
INSERT INTO veiculo(marca, modelo, cor, placa, tipo) VALUES("VOLKSWAGEN","GOLF GTI","PRETO","ABC1D231","CARRO") [42102-200]
application.properties
# datasource
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:fcamara-estacionamento
spring.datasource.username=sa
spring.datasource.password=
# jpa
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
# h2
# spring.h2.console.enabled=true
# spring.h2.console.path=/h2-console
Entidade Veiculo
@Entity
@Table(name="veiculo")
public class Veiculo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String marca;
private String modelo;
private String cor;
private String placa;
@Enumerated(EnumType.STRING)
private TipoVeiculo tipo;
public Veiculo(String marca, String modelo, String cor, String placa, TipoVeiculo tipo) {
this.marca = marca;
this.modelo = modelo;
this.cor = cor;
this.placa = placa;
this.tipo = tipo;
}
//GETTERS e SETTERS
Classe Main
@SpringBootApplication
public class BackendTestJavaApplication {
public static void main(String[] args) {
SpringApplication.run(BackendTestJavaApplication.class, args);
}
}