java系统库不加载opencv库



我在java项目中使用opencv库。我有一个简单的java项目,编译为'jar',并手动添加opencv库,然后,我知道我必须把这段代码放在后面:

System.loadLibrary (Core.NATIVE_LIBRARY_NAME);

这工作得很好,但是现在,我需要在服务器上运行相同的应用程序,所以我做了一个maven简单的项目,在'war'中编译,并在依赖项中添加了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正在编译,但是当我执行它时,那行失败了,我得到了同样的错误。

我读到我必须将opencv添加到我的系统变量中,但这不起作用

您可以将"opencv_java249.dll"文件添加到java/bin/文件夹(您已经安装了java)

(是的,这是对我的回答,因为我想帮助那些在同样的事情上遇到麻烦的人)

相关内容

  • 没有找到相关文章

最新更新