小编Rod*_*sta的帖子

Flyway 和 gradle kotlin dsl

我正在从 Gradle 迁移到 Gradle Kotlin DSL,我有一个问题。有

flyway {
    url = System.getenv ('DB_URL')
    user = System.getenv ('DB_USER')
    password = System.getenv ('DB_PASSWORD')
    baselineOnMigrate = true
    locations = ["filesystem: resources / db / migration"]
}
Run Code Online (Sandbox Code Playgroud)

在 Gradle 中。

你会如何看待 Kotlin DSL?

gradle flyway kotlin gradle-kotlin-dsl

6
推荐指数
1
解决办法
1872
查看次数

使用 Spring Boot 注入 MockMvc 时出错

我正在尝试使用 mockmvc 但它总是显示错误:

引起:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“org.springframework.test.web.servlet.MockMvc”类型的合格bean:预计至少有1个符合自动装配候选资格的bean。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true)}

我的课:

@AutoConfigureMockMvc
@ExtendWith(SpringExtension.class)
@TestPropertySource(locations = "classpath:application-cliente.properties")
public class ClienteRepositoryTest {

    @Autowired
    private MockMvc mockMvc;

    @MockBean
    private ClienteService clienteService;

    @Test
    public void simpleMockTest() throws Exception {
        var clienteMock = new Cliente("Jessica Pereira");
        Mockito.doReturn(Optional.of(clienteMock)).when(clienteService).buscar(2L);
        this.mockMvc.perform(MockMvcRequestBuilders.get("/api/clientes/pf/{id}", 1L))
                .andExpect(MockMvcResultMatchers.status().isOk());
    }
}
Run Code Online (Sandbox Code Playgroud)

还有我的毕业

plugins {
    id 'org.springframework.boot' version '2.1.3.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

group = 'com.rjdesenvolvimento'
version = '0.0.1'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/milestone' }
} …
Run Code Online (Sandbox Code Playgroud)

mocking spring-boot junit5

2
推荐指数
1
解决办法
3440
查看次数

Spring Boot、MongDB 和 Kotlin

我正在尝试在我的文档中添加一个唯一的复合键,如下所示:

@Document
@CompoundIndexes({
    CompoundIndex(def = "{'firstName':1, 'lastName':1}", name = "compound_index_1", unique = true)
})
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

An annotation argument must be a compile-time constant.
Run Code Online (Sandbox Code Playgroud)

有谁能够帮助我?

mongodb kotlin spring-boot

0
推荐指数
1
解决办法
188
查看次数