在intellij中安装or-tools库

时间:2019-04-17 20:20:50

标签: java intellij-idea or-tools

我正在尝试在我的intellij gradle项目中添加google或工具库。

不幸的是,我找不到要安装的任何Maven / gradle库。

此刻,我刚刚从以下链接下载了Java库:

https://developers.google.com/optimization/install/java/windows

并将目录复制并粘贴到我的项目中。

在目录中找到以下Java库:

  • com.google.ortools.jar
  • jniortools.dll
  • Knapsack.jar
  • ortools.lib
  • protobuf.jar
  • RabbitsPheasants.jar
  • SimpleLpProgram.jar
  • SimpleMipProgram.jar
  • SimpleSatProgram.jar
  • Tsp.jar
  • Vrp.jar

在我的 build.gradle 文件中,我使用了以下代码:

plugins {
id 'java'
id 'application'
}

group 'ORScheduling'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

applicationDefaultJvmArgs = ["-Djava.library.path=...\\ORSchedulingGradle\\lib"]

repositories {
     mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
 }

代码正在运行,但是出现以下错误

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil(file:/C:.../ORSchedulingGradle/lib/protobuf.jar) to field 
java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

此外,每次我更改gradle并自动更新时,都必须再次手动导入包含所有下载的Java库的目录。

有什么办法避免警告吗?

1 个答案:

答案 0 :(得分:1)

警告是来自protobuf库的众所周知的警告(它是or-tools的依赖项)。这还不是错误。

请参见https://github.com/protocolbuffers/protobuf/issues/3781

protobuf> = 3.7.0似乎可以解决此问题。

or-tools的下一版本将使用protobuf 3.7.1构建。