首先,我想说这是对我昨天发布的一个问题的跟进,我自己解决了问题(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:我试图尽可能详细地提出这个问题。如果需要更多信息,我可以立即提供。
答案 0 :(得分:1)
导入功能允许导入单个类或包中的所有类。单独一个包不能导入 - 它没有意义。
(import some.pack.SomeClass)
和
(import another.pack.*)
如果您需要访问类的静态成员,则必须使用特定表单。然后可以将静态视为用户函数:
(SomeClass.MAX_NUMBER_OF_X)