Я смог решить эту проблему самостоятельно, используя приведенный ниже код.
User.java
@Data
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long userId;
private String name;
}
DataSqlApplication.java
@SpringBootApplication
public class DataSqlApplication {
public static void main(String[] args) {
SpringApplication.run(DataSqlApplication.class, args);
}
}
application.yml
---
spring:
datasource:
url: jdbc:postgresql://localhost:5432/test?currentSchema=test
username: postgres
password: admin
platform: postgres
initialization-mode: always
schema:
- classpath:sql/schema.sql
data:
- classpath:sql/data.sql
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
properties:
hibernate:
default_schema: test
format_sql: true
jdbc:
lob:
non_contextual_creation: true
show-sql: true
hibernate:
ddl-auto: none
generate-ddl: false
profiles:
active:
- local
# Logging
logging:
level:
org.springframework.data: debug