类 尽管库包含在 pom 中,但在 Maven 项目中找不到
Classes not found in maven project despite the library being included in the pom
我正在尝试 运行 这个开源项目,rokuality-server(完整代码库在这里:https://github.com/rokuality/rokuality-server)。
但是在下面的这个方法中,我在尝试实例化任何 Sikuli class 时得到一个 java.lang.NoClassDefFoundError
,例如 Pattern
或 Finder
。
import org.sikuli.script.Finder;
import org.sikuli.script.Image;
import org.sikuli.script.Match;
import org.sikuli.script.Pattern;
@SuppressWarnings("unchecked")
public class ImageUtils {
private static JSONObject getElement(String sessionID, String locator, File screenImage) {
JSONObject element = new JSONObject();
element.put(SessionConstants.ELEMENT_ID, UUID.randomUUID().toString());
boolean isFile = locator != null && new File(locator).exists();
boolean elementFound = false;
if (!screenImage.exists()) {
return null;
}
if (isFile) {
Finder finder = null;
float similarity = Float.valueOf(
SessionManager.getSessionInfo(sessionID).get(SessionConstants.IMAGE_MATCH_SIMILARITY).toString());
Pattern pattern = null;
try {
//******** THIS LINE BELOW THROWS THE ERROR ********
pattern = new Pattern(locator).similar(similarity);
finder = new Finder(screenImage.getAbsolutePath());
} catch (Exception e) {
Log.getRootLogger().warn(e);
}
}
// more code here
}
}
我怀疑 pom.xml
文件中的某些内容是错误的,所以这里是 Sikuli X Api 依赖项,因为它出现在那里:
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.vidstige</groupId>
<artifactId>jadb</artifactId>
</exclusion>
<exclusion>
<groupId>com.sikulix</groupId>
<artifactId>sikulix2tigervnc</artifactId>
</exclusion>
</exclusions>
</dependency>
我尝试将版本更改为最新版本,2.0.0
但是它在项目中造成了一些错误,我认为这与 org.sikuli.script.Image
class 的更改有关方法。我可能需要更早的版本吗?
这应该在 rokuality 项目的较新版本中得到修复:
https://github.com/rokuality/rokuality-server/releases。这取决于用户使用的 java jdk 版本 运行。
我正在尝试 运行 这个开源项目,rokuality-server(完整代码库在这里:https://github.com/rokuality/rokuality-server)。
但是在下面的这个方法中,我在尝试实例化任何 Sikuli class 时得到一个 java.lang.NoClassDefFoundError
,例如 Pattern
或 Finder
。
import org.sikuli.script.Finder;
import org.sikuli.script.Image;
import org.sikuli.script.Match;
import org.sikuli.script.Pattern;
@SuppressWarnings("unchecked")
public class ImageUtils {
private static JSONObject getElement(String sessionID, String locator, File screenImage) {
JSONObject element = new JSONObject();
element.put(SessionConstants.ELEMENT_ID, UUID.randomUUID().toString());
boolean isFile = locator != null && new File(locator).exists();
boolean elementFound = false;
if (!screenImage.exists()) {
return null;
}
if (isFile) {
Finder finder = null;
float similarity = Float.valueOf(
SessionManager.getSessionInfo(sessionID).get(SessionConstants.IMAGE_MATCH_SIMILARITY).toString());
Pattern pattern = null;
try {
//******** THIS LINE BELOW THROWS THE ERROR ********
pattern = new Pattern(locator).similar(similarity);
finder = new Finder(screenImage.getAbsolutePath());
} catch (Exception e) {
Log.getRootLogger().warn(e);
}
}
// more code here
}
}
我怀疑 pom.xml
文件中的某些内容是错误的,所以这里是 Sikuli X Api 依赖项,因为它出现在那里:
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.vidstige</groupId>
<artifactId>jadb</artifactId>
</exclusion>
<exclusion>
<groupId>com.sikulix</groupId>
<artifactId>sikulix2tigervnc</artifactId>
</exclusion>
</exclusions>
</dependency>
我尝试将版本更改为最新版本,2.0.0
但是它在项目中造成了一些错误,我认为这与 org.sikuli.script.Image
class 的更改有关方法。我可能需要更早的版本吗?
这应该在 rokuality 项目的较新版本中得到修复: https://github.com/rokuality/rokuality-server/releases。这取决于用户使用的 java jdk 版本 运行。