【问题标题】:ShrinkWrap Maven resolver can't find war artifact in local repoShrinkWrap Maven 解析器在本地仓库中找不到战争工件
【发布时间】:2015-03-24 08:00:14
【问题描述】:

我有一个集成测试,我正在使用 Arquillian 和 ShrinkWrap 解析器在 Wildfly 中部署 2 个 Web 服务。这两个服务都是独立的,因此在任何 Maven 依赖意义上都不依赖于另一个。服务 2 对服务 1 进行 HTTP 调用。这纯粹是一个 B2B 场景,其中一个组件调用另一个组件。 也就是说,这是我的测试。问题是,Arquillian 未能部署服务 1。由于 ShrinkWrap 错误消息毫无用处(实际上没有消息),我试图找出我做错了什么。我已验证服务 1 的工件确实存在于我的本地 Maven 存储库中。

@Deployment(name = AVAILABILITY_SERVICE_NAME, order = 1)
public static WebArchive createAvailabilityServiceDeployment() {
    WebArchive availabilityService = Maven.configureResolver()
        .workOffline().withMavenCentralRepo(false)
        .withClassPathResolution(true)
        .resolve(AVAILABILITY_SERVICE_MVN_COORD).withoutTransitivity()
        .asSingle(WebArchive.class);

    System.out.println(availabilityService.toString(true));

    return availabilityService;
}

@Deployment(name = APPOINTMENT_SERVICE_NAME, order = 2)
public static WebArchive createAppointmentServiceDeployment()
        throws FileNotFoundException {
    WebArchive appointmentService = create(WebArchive.class,
        APPOINTMENT_SERVICE_NAME + ".war").addPackages(true,
        Filters.exclude(".*Test.*"), AppointmentApp.class.getPackage())
        .addAsWebInfResource(EmptyAsset.INSTANCE,
            ArchivePaths.create("beans.xml"));

    System.out.println(appointmentService.toString(true));

    return appointmentService;
}

java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive name.abhijitsarkar.microservices.appointment.AppointmentResourceIT.createAvailabilityServiceDeployment()
    at org.jboss.shrinkwrap.resolver.spi.format.FormatProcessors.find(FormatProcessors.java:53)
    at org.jboss.shrinkwrap.resolver.impl.maven.MavenFormatStageImpl.as(MavenFormatStageImpl.java:82)
    at org.jboss.shrinkwrap.resolver.impl.maven.MavenFormatStageImpl.asSingle(MavenFormatStageImpl.java:100)
    at name.abhijitsarkar.microservices.appointment.AppointmentResourceIT.createAvailabilityServiceDeployment(AppointmentResourceIT.java:50)

【问题讨论】:

    标签: maven integration-testing jboss-arquillian shrinkwrap


    【解决方案1】:

    显然,它需要分两步完成。希望对其他人有所帮助。

    private static WebArchive createDependentServiceDeployment(String name) {
        String mvnCoordinate = join(":", DEPENDENT_SERVICE_GROUP, name,
            DEPENDENT_SERVICE_PACKAGING, DEPENDENT_SERVICE_VERSION);
        File service = Maven.configureResolver().workOffline()
            .withMavenCentralRepo(false).withClassPathResolution(true)
            .resolve(mvnCoordinate).withoutTransitivity().asSingleFile();
    
        return ShrinkWrap.create(ZipImporter.class,
            join(".", name, DEPENDENT_SERVICE_PACKAGING))
           .importFrom(service).as(WebArchive.class);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-23
      • 2021-02-16
      • 2012-05-14
      • 1970-01-01
      • 1970-01-01
      • 2017-08-21
      • 1970-01-01
      相关资源
      最近更新 更多