我创建了非常简单的崩溃命令
@Usage("Echo")
public class echo extends BaseCommand {
@Command
@Usage("Echo")
public String main() throws IOException, InterruptedException {
InvocationContextImpl ctx = (InvocationContextImpl) context;
return ctx.readLine("Msg: ", true);
}
}
它工作正常。但是当我添加非常简单的pojo类
时package sth;
public class Echo {
private String echo;
public String getEcho() {
return echo;
}
public void setEcho(String echo) {
this.echo = echo;
}
}
我的命令:
InvocationContextImpl ctx = (InvocationContextImpl) context;
String msg = ctx.readLine("Msg: ", true);
Echo echo = new Echo();
echo.setEcho(msg);
return echo.getEcho();
仅当我从Idea运行时才有效。当我编译并运行时
mvn clean install
java -jar target/testproject-0.0.1-SNAPSHOT.jar
这给了我一个错误:
org.crsh.shell.impl.command.spi.CommandException: Could not compile command
at
...
Caused by: org.crsh.lang.impl.java.CompilationFailureException: package sth does not exist
cannot find symbol
symbol: class Echo
location: class crash.commands.echo
cannot find symbol
symbol: class Echo
location: class crash.commands.echo
但是当我从Idea运行时,一切正常。