我似乎无法让 flyway 知道在哪里寻找我的迁移。我的文件结构是从 spring 初始化生成的默认文件。我的迁移在:./demo/src/main/kotlin/db/migration 我的迁移是基于 Java 的
我的 application.properties 文件如下所示:
spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.url=jdbc:postgresql://${JDBC_DATABASE_URL}/jpaTestDatabase
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}
spring.flyway.baseline-on-migrate=true
spring.flyway.locations=classpath:demo/src/main/kotlin/db/migration
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=validate
spring.session.store-type=none
Run Code Online (Sandbox Code Playgroud)
我尝试了几个类路径:
/demo/src/main/kotlin/db/migration
demo/src/main/kotlin/db/migration
/src/main/kotlin/db/migration
src/main/kotlin/db/migration
Run Code Online (Sandbox Code Playgroud)
以上似乎都不起作用。
我怎样才能让 flyway 知道迁移的位置?
我正在尝试使用Kotlin Spring Boot,JPA和PostgreSQL配置Flyway。我的gradle依赖项是:
dependencies {
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('com.fasterxml.jackson.module:jackson-module-kotlin')
implementation('org.flywaydb:flyway-core')
implementation('com.google.code.gson:gson')
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect")
runtimeOnly('org.postgresql:postgresql')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
Run Code Online (Sandbox Code Playgroud)
我的application.properties文件是:
spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.url=jdbc:postgresql://${JDBC_DATABASE_URL}/jpaTestDatabase
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}
flyway.baseline-on-migrate=true
flyway.locations=classpath:src/main/kotlin/db/migration
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=validate
spring.session.store-type=none
Run Code Online (Sandbox Code Playgroud)
使用jpa和hibernate创建表和条目的工作符合预期。但是,在空数据库上进行示例迁移将导致:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]:
Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException:
Found non-empty schema(s) "public" without schema history table! Use baseline() or set baselineOnMigrate to true to initialize the schema history table.
Run Code Online (Sandbox Code Playgroud)
我的目录结构是spring initializr生成的默认目录结构,我的迁移在: demo/src/main/kotlin/db/migration
我只有一个迁移,这是在此处找到的示例迁移的kotlinized版本,我对其进行了调整以使其符合以下条件:
class V1__Sample : BaseJavaMigration() …
Run Code Online (Sandbox Code Playgroud) 在 Django 我可以这样做:
<head>
{% block content %}
(....) ---------> content from a partial template goes here.
{% endblock %}
(....) ---------> I can add aditional stuff here if I need to.
<head>
Run Code Online (Sandbox Code Playgroud)
我喜欢的地方。(例如:在所有模板中使用相同的头部,但一个页面需要额外的 css 文件或脚本)
我知道在 thymeleaf 中,我需要将整个标签定义为一个片段,我无法再向其中添加任何其他内容并且需要按原样使用。
我的问题是我将如何在百里香叶中实现上述示例?
在Kotlin我有两个列表:
val x: List<Int> = listOf(1,2,3,4,5,6)
val y: List<Int> = listOf(2,3,4,5,6,7)
Run Code Online (Sandbox Code Playgroud)
如何得到:
val z: List<Int> = 3,5,7,9,11,13
Run Code Online (Sandbox Code Playgroud)
没有使用循环?
我正在使用Kotlins KClass按名称查找类,如下所示:
val i: KClass<*> = Class.forName("SampleClass").kotlin
Run Code Online (Sandbox Code Playgroud)
但是,我想省略接口.到目前为止,我通过构造函数区分接口和类.
val i: KClass<*> = Class.forName(input).kotlin
if (i.constructors.isEmpty()){
println("This is an interface")
}else{
println("This is a class")
}
Run Code Online (Sandbox Code Playgroud)
我不认为它很干净.我正在寻找一些类似的东西
i.isInterface
Run Code Online (Sandbox Code Playgroud)
这样的事情存在吗?
我有一个字符串 "Hello World"
我需要一个Map<Char, Int>
包含每个字符的对和它在字符串中出现的次数:{H=1, e=1, l=3, o=2,r=1, d=1}
如果不使用传统的for循环,我怎么能这样做呢?