假设我有4个Maven模块:
-main
|-core (OpenCV is included here)
|-web (REST services that should use core services with OpenCV)
|-app (simple desktop app that also uses OpenCV through core services)
我想这样做,以便有一个处理图像处理的模块和应该使用它的其他模块。
另一个暗示:我正在使用Eclipse Mars
(4.5.0)。
我的问题是,当我将OpenCV添加为本机库(在Preferences
中)时,我无法使用Maven编译我的代码,因为它会出现如下错误:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.617 s
[INFO] Finished at: 2016-06-26T19:32:48+02:00
[INFO] Final Memory: 14M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project smilecounter.services: Compilation failure: Compilation failure:
[ERROR] Path/Service.java:[1,23] package org.opencv.core does not exist
[ERROR] Path/Service.java:[2,23] package org.opencv.core does not exist
[ERROR] Path/Service.java:[7,17] cannot find symbol
[ERROR] symbol: class Mat
[ERROR] location: class Service
[ERROR] Path/Service.java:[7,40] cannot find symbol
[ERROR] symbol: variable CvType
[ERROR] location: class Service
[ERROR] Path/Service.java:[7,26] cannot find symbol
[ERROR] symbol: variable Mat
[ERROR] location: class Service
当我使用main
方法创建类时,OpenCV正常工作。
所以,我尝试了另一种方法:在项目中添加maven依赖项(不是最新版本,但仍值得尝试......)。
<!-- https://mvnrepository.com/artifact/nu.pattern/opencv -->
<dependency>
<groupId>nu.pattern</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-4</version>
</dependency>
这一次,Maven编译工作正常,如果我在Build Path
中有本机类,它似乎适用于app
模块,但web
模块给出了错误:
19:53:05,575 ERROR [io.undertow.request] (default task-97) UT005023: Exception handling request to /SC/rest/snapshot/send: org.jboss.resteasy.spi.UnhandledException: java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path
我的问题是:是否可以在我的OpenCV
中加入core-services.jar
库,这样我就不必配置项目了?如何配置服务器(WildFly 10
)以正确使用此库?