在模块化Java应用程序中使用剧作家

发布于 2025-02-10 11:46:28 字数 1738 浏览 0 评论 0原文

我想在我的模块化Java应用程序中使用 playwright 库。

这是我的主要课程:

package group.test;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;

public class App 
{
  public static void main(String[] args) 
  {
    try (Playwright playwright = Playwright.create()) 
    {
      Browser browser = playwright.chromium().launch();
      Page page = browser.newPage();
      page.navigate("http://playwright.dev");
      System.out.println(page.title());
    }
  }
}

这是相应的 module.info 文件:

module App.module 
{
      requires playwright;
}

当我尝试使用Maven的 maven-jlink-plugin 尝试构建此项目时,我会收到以下错误:

[INFO] --- maven-jlink-plugin:3.1.0:jlink (default-jlink) @ test ---
[INFO]  -> module: driver ( C:\Users\User\.m2\repository\com\microsoft\playwright\driver\1.17.1\driver-1.17.1.jar )
[INFO]  -> module: playwright ( C:\Users\User\.m2\repository\com\microsoft\playwright\playwright\1.17.1\playwright-1.17.1.jar )
[INFO]  -> module: com.google.gson ( C:\Users\User\.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar )
[INFO]  -> module: driver.bundle ( C:\Users\User\.m2\repository\com\microsoft\playwright\driver-bundle\1.17.1\driver-bundle-1.17.1.jar )
[INFO]  -> module: App.module ( D:\programming\eclipse-workspace\test\target\classes )
[ERROR]
[ERROR] Error: Module driver.bundle contains package com.microsoft.playwright.impl, module playwright exports package com.microsoft.playwright.impl to driver.bundle

我是Java模块系统的新手 - 显然问题是 driver.bundle 模块(随附playwright?)需要一个模块,该模块会导出一个包装 driver.bundle 已经包含自己。这是可以固定在我身边的东西(作为用户)吗?

I would like to use the Playwright library in my modular Java application.

This is my main class:

package group.test;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;

public class App 
{
  public static void main(String[] args) 
  {
    try (Playwright playwright = Playwright.create()) 
    {
      Browser browser = playwright.chromium().launch();
      Page page = browser.newPage();
      page.navigate("http://playwright.dev");
      System.out.println(page.title());
    }
  }
}

And this is the corresponding module.info file:

module App.module 
{
      requires playwright;
}

When I try to build this project using maven's maven-jlink-plugin I get the following error:

[INFO] --- maven-jlink-plugin:3.1.0:jlink (default-jlink) @ test ---
[INFO]  -> module: driver ( C:\Users\User\.m2\repository\com\microsoft\playwright\driver\1.17.1\driver-1.17.1.jar )
[INFO]  -> module: playwright ( C:\Users\User\.m2\repository\com\microsoft\playwright\playwright\1.17.1\playwright-1.17.1.jar )
[INFO]  -> module: com.google.gson ( C:\Users\User\.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar )
[INFO]  -> module: driver.bundle ( C:\Users\User\.m2\repository\com\microsoft\playwright\driver-bundle\1.17.1\driver-bundle-1.17.1.jar )
[INFO]  -> module: App.module ( D:\programming\eclipse-workspace\test\target\classes )
[ERROR]
[ERROR] Error: Module driver.bundle contains package com.microsoft.playwright.impl, module playwright exports package com.microsoft.playwright.impl to driver.bundle

I'm new to Java's module system - apparently the problem is that the driver.bundle module (which comes with Playwright?) requires a module which exports a package which driver.bundle already contains itself. Is this something which can be fixed on my side (as a user) and if so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文