我正在尝试使用烧烤条形码打印库。我通过project structure add library成功将库添加到IntelliJ。然后我导入了包并编写了方法,这没有给我任何错误。这些包在类中可用。

但是当我编译时,它会给我一个错误:

error: package net.sourceforge.barbecue does not exist

这怎么可能呢?

我在ubuntu中编码,还有其他地方需要添加库吗?


当前回答

无效缓存为我工作,但它太长时间来恢复缓存,所以我没有耐心等待它。我找到了另一种方法来解决我的问题。“修复IDE”步骤3(删除包搜索项目缓存)为我完美地工作

其他回答

我尝试了所有的答案,但最终帮助我的是将Maven从捆绑到我自己的Maven发行版。

我认为反之亦然(从自己的改变到捆绑)也会有所帮助。

只是重新导入不起作用。下面的方法对我很有效。

File ->使缓存失效/重新启动

Then

Build ->重建项目

这将重新导入maven项目。

注意:您需要使缓存无效并重新构建项目。

在我的案例中,问题是IntelliJ和settings.xml文件中有不同的存储库目录配置。

检查两个存储库目录是否相同:

IntelliJ(文件>设置>构建,执行,部署>构建工具> Maven)

settings.xml (通常在c:\ users \myuser\。M2或/home/myuser/.m2)

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  ...
  <localRepository>C:\Users\myuser\.m2\repository</localRepository>
  ...
</settings>

修复目录后运行:

为所有项目生成文件夹和更新源

重新导入所有maven项目

package com.example;

import com.sun.jna.Library;
import com.sun.jna.Native;

public class C {
    public interface Kernel32 extends Library {
        public void OutputDebugStringA(String Text);
        public void DebugBreak();
        public void Sleep(int a);
    }

    public static int incint(int in1)
    {
        testpkg.xxxBird.Say("xxxee"); //only use this statement to call external lib
                                      //I don't use "import" statement.
        return in1*2;
    }
}

我正在使用intellij的想法。 您需要在项目依赖项中添加testpkg路径。

无效缓存为我工作,但它太长时间来恢复缓存,所以我没有耐心等待它。我找到了另一种方法来解决我的问题。“修复IDE”步骤3(删除包搜索项目缓存)为我完美地工作