Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我能';在我的JavaFX项目中,不要将HtmlUnitDriver与Maven一起使用_Java_Maven_Javafx_Htmlunit Driver - Fatal编程技术网

我能';在我的JavaFX项目中,不要将HtmlUnitDriver与Maven一起使用

我能';在我的JavaFX项目中,不要将HtmlUnitDriver与Maven一起使用,java,maven,javafx,htmlunit-driver,Java,Maven,Javafx,Htmlunit Driver,我试图在我的JavaFX项目中使用HtmlUnitDriver,但是当我添加HtmlUnitDriver时,我得到了这些错误 我尝试了不同的版本,但仍然是相同的错误,我不知道该怎么办 Caused by: java.lang.ClassNotFoundException: org.apache.xml.utils.PrefixResolver Caused by: java.lang.ClassNotFoundException: org.apache.xml.utils.PrefixResol

我试图在我的JavaFX项目中使用HtmlUnitDriver,但是当我添加HtmlUnitDriver时,我得到了这些错误 我尝试了不同的版本,但仍然是相同的错误,我不知道该怎么办

Caused by: java.lang.ClassNotFoundException: org.apache.xml.utils.PrefixResolver
Caused by: java.lang.ClassNotFoundException: org.apache.xml.utils.PrefixResolver
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 45 more
在我的JavaFX项目中只有一个类

类Main.java包含以下代码


  package com.ali.chegg.chegg;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

/**
 * JavaFX App
 */
public class App extends Application {

    private static Scene scene;

    @Override
    public void start(Stage stage) throws IOException {
        
 AnchorPane p=new AnchorPane();
                Label lbl = new Label("Title);
                Button b=new Button("get title");
                b.setLayoutX(100);
                b.setOnAction((t) -> {
                 HtmlUnitDriver d=new HtmlUnitDriver();
                 d.get("https://www.google.com");
                 lbl.setText(d.getTitle());
                });
                p.getChildren().addAll(lbl,b);
        scene = new Scene(p,640, 480);
        stage.setScene(scene);
        stage.show();
 
    }

    
    public static void main(String[] args) {
 
             
        launch(args);

    }

}
和POM.xml文件:

  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ali.chegg</groupId>
    <artifactId>Chegg</artifactId>
    <version>1.0</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>14</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>14</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-htmlunit-driver -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    <version>2.0.0</version>
    <type>jar</type>
</dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <mainClass>com.ali.chegg.chegg.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.ali.chegg
切格
1
UTF-8
11
11
org.openjfx
javafx控件
14
org.openjfx
javafx-fxml
14
org.seleniumhq.selenium
selenium htmlunit驱动程序
2.0.0
罐子
org.apache.maven.plugins
maven编译器插件
3.8.0
11
org.openjfx
javafxmaven插件
0.0.4
com.ali.chegg.chegg.App

顺便说一句,我使用的是Apache NetBeans 11.3和jdk 14.0.1,您可以在这里找到有用的东西:您可以在这里找到有用的东西: