我遇到“更正您的应用程序的类路径,使其包含单个compa .....”这个问题,谁能给我一些解决方案?

时间:2019-08-10 07:21:02

标签: java

说明:

试图调用一个不存在的方法。尝试是从以下位置进行的:

net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:85)

以下方法不存在:

com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;)Lcom/sun/jna/Library;

可从以下位置获得该方法的类com.sun.jna.Native:

jar:file:/D:/Maven/mvnrep/net/java/dev/jna/jna/4.5.2/jna-4.5.2.jar!/com/sun/jna/Native.class

它是从以下位置加载的:

file:/D:/Maven/mvnrep/net/java/dev/jna/jna/4.5.2/jna-4.5.2.jar

操作:

更正应用程序的类路径,使其包含com.sun.jna.Native的单个兼容版本

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <groupId>cn.kexie</groupId>
    <artifactId>kexie.HolidayAssessment</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>

        <!-- selenium 动态爬取-->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- jdbc驱动-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <!-- Spring boot web-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- mysql 连接依赖-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- jsoup 依赖-->
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.8.1</version>
        </dependency>
        <!-- 验证码识别依赖-->
        <dependency>
            <groupId>net.sourceforge.tess4j</groupId>
            <artifactId>tess4j</artifactId>
            <version>4.4.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.sun.jna</groupId>
                    <artifactId>jna</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>

        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>6</source>
                    <target>6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

  public static List<String> doGetHtml(){
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.get(URL);

        List<String> pageHtml = new ArrayList<String>();
        //输入用户名以及密码
        driver.findElement(By.id("textfield-1013-bodyEl")).findElement(By.id("textfield-1013-inputEl")).sendKeys(USER_NAME);
        driver.findElement(By.id("textfield-1014-bodyEl")).findElement(By.id("textfield-1014-inputEl")).sendKeys(PASSWORD);

        //截取全屏
        //截取全屏 并截取至验证码部分
        try {
            File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
            BufferedImage image = ImageIO.read(src);
            image = image.getSubimage(1037, 516, 58, 16);
            ImageIO.write(image, "png", new File("D:\\javaCode\\kexieHolidayAssessment\\src\\main\\resources\\Image\\screen.png"));
            String s = IdentificationCode.process();
            //输入验证码
            driver.findElement(By.id("CheckCode-inputEl")).sendKeys(s);
            Thread.sleep(4000);

            //关闭公告窗口
            driver.findElement(By.cssSelector("#tool-1043")).click();
            Thread.sleep(2000);

            //选择  已选课程
            driver.findElement(By.id("treeview-1014-record-bstuk070")).click();
            Thread.sleep(2000);

            //点击下拉
            driver.findElement(By.id("ext-gen1193")).click();
            Thread.sleep(2000);

            List<WebElement> eles = driver.findElements(By.cssSelector("[class=x-list-plain]>li"));

            //选择2018-2019学期
            eles.get(3).click();
            Thread.sleep(3000);

            //点击查询
            driver.findElement(By.id("button-1050-btnIconEl")).click();
            Thread.sleep(2000);

            pageHtml.add(driver.getPageSource());

            //切换页面  再次获取
            driver.findElement(By.id("ext-gen1193")).click();
            Thread.sleep(3000);


            eles.get(2).click();

            Thread.sleep(3000);
            //点击查询
            driver.findElement(By.id("button-1050-btnIconEl")).click();
            Thread.sleep(2000);
            pageHtml.add(driver.getPageSource());

            //切换页面  再次获取
            driver.findElement(By.id("ext-gen1193")).click();
            Thread.sleep(3000);

            eles.get(1).click();

            Thread.sleep(3000);
            //点击查询
            driver.findElement(By.id("button-1050-btnIconEl")).click();
            Thread.sleep(2000);
            pageHtml.add(driver.getPageSource());
            driver.quit();

        }catch (Exception e){
            System.out.println(e.getMessage());
        }

我希望它可以运行,但是会告诉我这些错误。因此,我希望得到一些建议。

0 个答案:

没有答案