错误:包com.google.common.base不存在

绿色度:

给定以下Java代码,在编译时会出现很多错误:


Main.java:1:错误:包com.google.common.base不存在,请导入com.google.common.base.Preconditions; ^

Main.java:2:错误:包com.google.common.collect不存在,请导入com.google.common.collect.Lists;^

Main.java:3:错误:包org.ros.exception不存在import org.ros.exception.RosRuntimeException; ^

Main.java:4:错误:包org.ros.internal.loader不存在import org.ros.internal.loader.CommandLineLoader; ^

Main.java:5:错误:包org.ros.node不存在import org.ros.node.DefaultNodeMainExecutor; ^

Main.java:6:错误:包org.ros.node不存在import org.ros.node.NodeConfiguration; ^

Main.java:7:错误:包org.ros.node不存在import org.ros.node.NodeMainExecutor;

我通过IntelliJ运行它。有谁知道为什么它不起作用?

import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import org.ros.exception.RosRuntimeException;
import org.ros.internal.loader.CommandLineLoader;
import org.ros.node.DefaultNodeMainExecutor;
import org.ros.node.NodeConfiguration;
import org.ros.node.NodeMainExecutor;

// This class will run a publisher and subscriber, and relay data between them.

public class Main {

static private Talker pubNodeMain;

static private Listener subNodeMain;

public static void main(String[] argv) throws Exception {
    // Set up the executor for both of the nodes
    NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault();

    // Load the publisher
    String[] pubArgv = {"Talker"};
    CommandLineLoader pubLoader = new CommandLineLoader(Lists.newArrayList(pubArgv));
    String nodeClassName = pubLoader.getNodeClassName();
    System.out.println("Loading node class: " + pubLoader.getNodeClassName());
    NodeConfiguration pubNodeConfiguration = pubLoader.build();

    try {
        pubNodeMain = (Talker) pubLoader.loadClass(nodeClassName);
    } catch (ClassNotFoundException e) {
        throw new RosRuntimeException("Unable to locate node: " + nodeClassName, e);
    } catch (InstantiationException e) {
        throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
    } catch (IllegalAccessException e) {
        throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
    }

    Preconditions.checkState(pubNodeMain != null);
    nodeMainExecutor.execute(pubNodeMain, pubNodeConfiguration);

    // Load the subscriber
    String[] subArgv = {"Listener"};
    CommandLineLoader subLoader = new CommandLineLoader(Lists.newArrayList(subArgv));
    nodeClassName = subLoader.getNodeClassName();
    System.out.println("Loading node class: " + subLoader.getNodeClassName());
    NodeConfiguration subNodeConfiguration = subLoader.build();

    try {
        subNodeMain = (Listener) subLoader.loadClass(nodeClassName);
    } catch (ClassNotFoundException e) {
        throw new RosRuntimeException("Unable to locate node: " + nodeClassName, e);
    } catch (InstantiationException e) {
        throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
    } catch (IllegalAccessException e) {
        throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
    }

    Preconditions.checkState(subNodeMain != null);
    nodeMainExecutor.execute(subNodeMain, subNodeConfiguration);
  }

}
下载:
<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>11.0.2</version>
</dependency>

通过在pom.xml中添加依赖项,我能够解决问题

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

错误“包com_atlassian_clover不存在”

Maven,包不存在

包不存在错误!

NetBeans错误:包组织不存在

导入自定义程序包显示“错误:程序包com不存在”

java maven导入问题:错误:包com.google.gson不存在

弹簧启动包不存在错误

错误:包com.android.volley不存在

错误:包com.google.android.gcm不存在-迁移到Gradle之后

错误:包com.google.android.gms.appstate不存在

错误:包com.oculus.vrappframework不存在

java包com.google.common.collect.Range <LocalDate>交集返回错误的交集

google iosched示例项目:com.google.api.client.repackaged.com.google.common.base不存在

错误:包com.google.firebase.messaging不存在

包com.google.api.client.extensions.android.http不存在

包R不存在...。

Android Studio com.google.android.exoplayer2不存在错误

错误:包com.getcapacitor.community.firebasecrashlytic不存在

“错误:程序包com.google.firebase.iid不存在”更新Firebase Crashlytics依赖项后

错误包`com.google.android.gms ...`不存在

包com.google.android.gms.maps.model不存在

错误:当我安装Quartz.Net时,命名空间“ Common”中不存在

Xamarin-Google Cloud Messaging-错误:包com.google.android.gms.iid不存在

错误:(37,41)错误:包com.example.android.common.logger不存在

Deborphan 返回不存在的包 - 错误?

包 BottomNavigationView 不存在

错误:包 com.badlogic.gdx 不存在

Google Cloud Endpoint 错误:包 MyApi 不存在

包说不存在