小编pum*_*ump的帖子

Akka HTTP:如何将Json格式响应解组为域对象

我正在尝试Akka HTTP,我已经创建了一个服务,在HttpResponse中返回一个域对象的Json数组.在客户端中,我想将其转换为域对象的源,以便后续的流和接收器可以使用它.

参考Json支持部分:http: //doc.akka.io/docs/akka-stream-and-http-experimental/1.0/scala/http/common/json-support.html

我已经完成了定义隐式RootJsonReader等的必要,但我不知道如何使用FromEntityUnmarshaller.

我的代码在这里:https: //github.com/charlesxucheng/akka-http-microservice

它基于akka-http-microservice激活器模板.Service2.scala是我的服务器实现,并且正在运行.AkkaHttpClient.scala是客户端实现,它不完整.

要构建,请使用Gradle作为build.sbt不是最新的.

谢谢.

json scala reactive-streams akka-stream akka-http

8
推荐指数
1
解决办法
1306
查看次数

如何使用带有SpringFox @ EnableSwagger2的@DataJpaTest在Spring Boot 1.4中进行切片测试

回复:https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4

我尝试使用@DataJpaTest测试我的存储库,但我的应用程序使用的是Spring,因此使用Springfox @ EnableSwagger2时,测试执行将失败,并显示以下错误:

java.lang.IllegalStateException: Failed to load ApplicationContext
...    
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.List<org.springframework.web.servlet.mvc.method.requestmappinginfohandlermapping>' available
Run Code Online (Sandbox Code Playgroud)

可以做些什么来解决这个问题?否则,不可能使用@DataJpaTest进行切片测试.

码:

Application class:
@SpringBootApplication
@EnableSwagger2
public class CurrencyApplication {
  @Bean
  public Module datatypeHibernateModule() {
    return new Hibernate5Module();
  }

  public static void main(String[] args) {
    SpringApplication.run(CurrencyApplication.class, args);
  }

  @Bean
  public Docket currencyApi() {
    return new …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot springfox

5
推荐指数
1
解决办法
1455
查看次数

Scalatest Generator 驱动的属性检查 Eclipse 中的编译错误。好的,在 SBT 中。

我正在尝试使用 ScalaTest 进行基于属性的测试。我使用 2 个自定义生成器编写了一些测试用例,它们运行良好。然而,当我使用一个自定义生成器定义 forAll 时,如下所示:

  it should "generate a given number of weights whose total is less than the given total when the given number is > 0, with default upperBound, lowerBound and total" in {
    // TODO: Find out why single parameter does not work. maxSize here is a workaround
    forAll(reasonableSizes) { (size: Int) =>
      whenever(size > 0) {
        val range = random.nextLong.abs
        val values = DataGenerator.generatePartialWeights(size)
        values should have length size
        every(values) should (be >= BigDecimal(0) …
Run Code Online (Sandbox Code Playgroud)

scala implicit-conversion scalatest scalacheck scala-ide

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