小编Nur*_*din的帖子

Spring Cloud git 配置——将存储库放在直接包含类路径的文件夹中?

我想在应用程序的开发阶段将 git 存储库放在类路径正上方的文件夹中。

目前,我将此作为我的 Spring Cloud git URI:

spring.cloud.config.server.git.uri=file://${user.dir}/cloud-configuration-repository

此 URI 指向类路径正上方的文件夹。

但是,在运行时我收到此错误。

***************************
APPLICATION FAILED TO START
***************************

Description:

Invalid config server configuration.

Action:

If you are using the git profile, you need to set a Git URI in your configuration.  If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Run Code Online (Sandbox Code Playgroud)

编辑:这是我希望拥有的项目结构:

Project
??? _.idea
??? src
|   ??? main
|   ??? test
??? target
??? cloud-configuration-repository
Run Code Online (Sandbox Code Playgroud)

java cloud git spring spring-cloud

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

使用 Mockito 2 模拟通用 RestTemplate 将参数存根为 null 或空字符串

这是我的存根代码。使用适当的参数调用交换方法(显示在存根代码下方),但出于某种原因,该when().then()语句正在寻找空参数。为什么PotentialStubbingProblem这里抛出异常?

@BeforeEach
public <T> void configureMocks() {
    when(apiAccess.getKey()).thenReturn("abcdefghijklmnopqrstuvwxyz");
    when(apiAccess.getUrlPrefix()).thenReturn("{region}.api.riotgames.com");
    val response = new ResponseEntity<Collection<T>>(HttpStatus.OK);
    when(restTemplate.exchange(ArgumentMatchers.anyString(),
            ArgumentMatchers.any(HttpMethod.class),
            (HttpEntity<?>) isNull(),
            eq(new ParameterizedTypeReference<Collection<T>>() {})))
            .thenReturn(response);
}
Run Code Online (Sandbox Code Playgroud)

PotentialStubbingProblem 输出如下所示:

org.mockito.exceptions.misusing.PotentialStubbingProblem: 
Strict stubbing argument mismatch. Please check:
 - this invocation of 'exchange' method:
    restTemplate.exchange(
    https://JP1.api.riotgames.com/lol/champion-mastery/v3/champion-masteries/by-summoner/1234567890?api_key=abcdefghijklmnopqrstuvwxyz,
    GET,
    null,
    ParameterizedTypeReference<java.util.Collection<T>>
);
    -> at org.eyeoftheherald.riotapiinterface.service.RiotApiService.getEntityList(RiotApiService.java:176)
 - has following stubbing(s) with different arguments:
    1. restTemplate.exchange("", null, null, null);
Run Code Online (Sandbox Code Playgroud)

ApiAccess 如下图所示:

@Configuration
public class RiotApiInterfaceConfiguration {
    @Getter
    @Setter
    @Configuration
    @PropertySource("classpath:configuration.properties")
    @ConfigurationProperties(prefix = "api-access")
    public static class …
Run Code Online (Sandbox Code Playgroud)

java junit spring mockito resttemplate

5
推荐指数
0
解决办法
953
查看次数

标签 统计

java ×2

spring ×2

cloud ×1

git ×1

junit ×1

mockito ×1

resttemplate ×1

spring-cloud ×1