我在java项目中使用opencv库。我有一个简单的java项目,编译为' jar',并手动添加opencv库,然后,我知道我必须把这个代码放在什么之后:
的System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
这很好用,但是现在,我需要在服务器上运行相同的应用程序,所以我制作了一个简单的maven项目,可以在一场“战争”中编译。并在依赖项中添加了opencv,但是在上面的行中我得到了这个错误。
Caused by: java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path
我想这是真的,因为是一个maven依赖。 我怎么解决这个问题?
这是我的pom.xml
<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>org.springframework.samples</groupId>
<artifactId>RetinoblastomappSpring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<description>Tesis de diagnostico temprano retinoblastoma</description>
<properties>
<!-- Generic properties -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Spring -->
<spring-framework.version>3.2.3.RELEASE</spring-framework.version>
<!-- Hibernate / JPA -->
<hibernate.version>4.2.1.Final</hibernate.version>
<!-- Logging -->
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>
<!-- Test -->
<junit.version>4.11</junit.version>
<!-- OpenCV -->
<opencv.version>2.4.9-4</opencv.version>
</properties>
<dependencies>
<!-- Spring and Transactions -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- Logging with SLF4J & LogBack -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- Test Artifacts -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- OpenCV -->
<dependency>
<groupId>nu.pattern</groupId>
<artifactId>opencv</artifactId>
<version>${opencv.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
更新
我手动添加了库,并且是相同的,war正在编译OK,但是当我执行它时,该行失败并且我得到了相同的错误。
我读到我必须将opencv添加到我的系统变量中,但那不起作用
答案 0 :(得分:3)
您可以解决此问题,添加文件&#34; opencv_java249.dll&#34;到文件夹java / bin /(你已经安装了java)
(是的,这是对我的回答,因为我想帮助那些在同一件事上遇到麻烦的人)