ShrinkWrap Maven 解析器在本地仓库中找不到 war 工件

ShrinkWrap Maven resolver can't find war artifact in local repo

我有一个集成测试,我使用 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)

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

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);
}