Having a problem with H2 set up in Spring. I placed all my sql data into one file named data.sql, however when I change it to anything else - it cannot be identified. Any idea how to set up multiple separate files?
Let's say i have a table User and some data inserted, but aiming to have 2 separate files, e.g. user-schema and user-data, and so on - multiple schema files with same number of insert data files.
My current spring.properties looks as follows:
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.h2.console.path=/h2
My current data.sql looks as follows:
DROP TABLE IF EXISTS User;
CREATE TABLE User
(
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(20) NOT NULL,
surname VARCHAR(20) NOT NULL,
role VARCHAR(20) NOT NULL,
email VARCHAR(30) NOT NULL
);
INSERT INTO User (name, surname, role, email)
VALUES ('Thor', '', 'admin', 'thor@marvel.com'),
('Hulk', '', 'user', 'hulk@marvel.com'),
('Venom', '', 'user', 'venom@marvel.com'),
('Spider', 'Man', 'user', 'spider-man@marvel.com'),
('Super', 'Man', 'user', 'super-man@marvel.com');
Aucun commentaire:
Enregistrer un commentaire