gpt4 book ai didi

java - Maven 项目中的 Jess "Class not found"异常

转载 作者:行者123 更新时间:2023-12-01 11:59:03 24 4
gpt4 key购买 nike

首先,我想说这是我昨天发布的问题的后续,我自己解决了该问题(How to add Jess in Maven project?)。

这一次,轮到 Jess 在查找项目的类时遇到问题了。更具体地说,一切都运行良好,直到执行第一行 engine.batch("rules.clp"),我得到一个“类未找到异常”。

(import cz.cuni.amis.pogamut.ut2004.examples.huntbot)
(deftemplate HunterBot (declare (from-class HunterBot)))

包结构为:

-cz.cuni.amis.pogamut.ut2004.examples.huntbot
-- HunterBot.java

以下是 HunterBot.java 文件的第一行:

package cz.cuni.amis.pogamut.ut2004.examples.huntbot;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import jess.*;
import cz.cuni.amis.introspection.java.JProp;
import cz.cuni.amis.pogamut.base.agent.navigation.IPathExecutorState;
import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.EventListener;
import cz.cuni.amis.pogamut.base.utils.Pogamut;
import cz.cuni.amis.pogamut.base.utils.guice.AgentScoped;
import cz.cuni.amis.pogamut.base.utils.math.DistanceUtils;
import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
import cz.cuni.amis.pogamut.ut2004.agent.module.utils.TabooSet;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004PathAutoFixer;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004DistanceStuckDetector;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004PositionStuckDetector;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004TimeStuckDetector;
import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController;
import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
import cz.cuni.amis.pogamut.ut2004.communication.messages.UT2004ItemType;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Initialize;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Move;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Rotate;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Stop;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.StopShooting;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotDamaged;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotKilled;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Item;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerDamaged;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerKilled;
import cz.cuni.amis.pogamut.ut2004.utils.UT2004BotRunner;
import cz.cuni.amis.utils.exception.PogamutException;
import cz.cuni.amis.utils.flag.FlagListener;
import java.util.logging.Logger;

/**
* Example of Simple Pogamut bot, that randomly walks around the map searching for preys shooting at everything that is in its way.
*
* @author Rudolf Kadlec aka ik
* @author Jimmy
*/
@AgentScoped
public class HunterBot extends UT2004BotModuleController<UT2004Bot> {

Rete engine;
...

最后这是 pom.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<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>

<parent>
<groupId>cz.cuni.amis.pogamut.ut2004</groupId>
<artifactId>pogamut-ut2004-bot-pom</artifactId>
<version>3.6.1</version>
</parent>

<groupId>cz.cuni.amis.pogamut.ut2004.examples</groupId>
<artifactId>huntbot</artifactId>
<version>3.3.1</version>
<packaging>jar</packaging>

<name>04-hunter-bot</name>
<url>http://pogamut.cuni.cz</url>

<properties>
<bot.main.class>cz.cuni.amis.pogamut.ut2004.examples.huntbot.HunterBot</bot.main.class>
</properties>

<repositories>
<repository>
<id>amis-artifactory</id>
<name>AMIS Artifactory</name>
<url>http://diana.ms.mff.cuni.cz:8081/artifactory/repo</url>
</repository>


<repository>
<id>data-local</id>
<name>data</name>
<url>file://${project.basedir}/repo</url>
</repository>

</repositories>



<build>
<plugins>
<plugin>
<groupId>org.dstovall</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<configuration>
<mainClass>${bot.main.class}</mainClass>
</configuration>
</plugin>
</plugins>
</build>


<dependencies>

<dependency>
<groupId>gov.sandia</groupId>
<artifactId>jess</artifactId>
<version>7.1p2</version>
<scope>compile</scope>
</dependency>

</dependencies>


</project>

jess-7.1p2.jar 文件位于 (base.dir)\repo\gov\sandia\jess\7.1p2\。它被识别没有问题。

PS:我试图尽可能详细地回答这个问题。如果需要更多信息,我可以立即提供。

最佳答案

导入功能允许导入单个类或包中的所有类。无法单独导入包 - 这没有意义。

(import some.pack.SomeClass)

(import another.pack.*)

如果您需要访问类的静态成员,您必须使用特定的形式。然后,静态数据就可以像用户函数一样使用:

(SomeClass.MAX_NUMBER_OF_X)

关于java - Maven 项目中的 Jess "Class not found"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28125008/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com