Maven project does not referenced sikuli-api dependency in java

好久不见. 提交于 2021-02-19 07:09:20

问题


I created Maven Project and I have an error, I think dependencies does not work. pom.xml file does not read properly. pom.xml file has red x icon on it.

I edited the error is:

Missing artifact com.sikulix:sikulixapi:jar:1.1.0

and this is my pom.xml file;

  <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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test.selin</groupId>
  <artifactId>automation</artifactId>
  <version>1.1.0-SNAPSHOT</version>
  <name>automation</name>
 <repositories>
  <repository>
    <id>com.sikulix</id>
    <name>com.sikulix</name>
    <url>https://oss.sonatype.org/content/groups/public</url>
    <layout>default</layout>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
    </snapshots>
  </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>com.sikulix</groupId>
    <artifactId>sikulixapi</artifactId>
    <version>1.1.0</version>
    </dependency>
  </dependencies>
</project>

This is my class:

import org.sikuli.script.App;
import org.sikuli.script.Screen;

public class DefineObjects {

    public static void main(String[] args) {
        App.open("G:\\mywork\\app.exe");

        Screen s = new Screen();

        s.wait("imgs\\a.png", 9000);
        s.find("imgs\\b.png");
        s.click();
    }
}

回答1:


Sikuli was now renamed SikuliX. You can depend on Sikuli Script by having this single dependency:

<dependency>
    <groupId>com.sikulix</groupId>
    <artifactId>sikulixapi</artifactId>
    <version>1.1.0</version>
</dependency>

As a side-note, you don't need to specify <packaging>jar</packaging> in your POM since this is the default value. The same goes for <url>http://maven.apache.org</url>.

As such, this would be the corrected and simplified POM:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test.selin</groupId>
  <artifactId>automation</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>automation</name>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.sikulix</groupId>
      <artifactId>sikulixapi</artifactId>
      <version>1.1.0</version>
    </dependency>
  </dependencies>
</project>



回答2:


This worked for me:

<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>

  <groupId>com.aiur</groupId>
  <artifactId>GUIAutomationTest</artifactId>
  <version>0.0.1</version>
  <packaging>jar</packaging>

  <name>GUIAutomationTest</name>
  <url>http://maven.apache.org</url>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.5.RELEASE</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
  </properties>

  <repositories>
    <repository>
        <!-- OSSRH: com.sikulix -->
        <id>com.sikulix</id>
        <name>com.sikulix</name>
        <url>https://oss.sonatype.org/content/groups/public</url>
        <layout>default</layout>
        <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <!-- <version>3.8.1</version> -->
      <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.sikulix</groupId>
        <artifactId>sikulixapi</artifactId>
        <!-- <version>1.1.0</version> -->
        <version>1.1.4-SNAPSHOT</version>
    </dependency>

  </dependencies>

  <build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
  </build>

</project>


来源:https://stackoverflow.com/questions/34672702/maven-project-does-not-referenced-sikuli-api-dependency-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!