Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 无法编译命令-包不存在_Spring Boot_Crash - Fatal编程技术网

Spring boot 无法编译命令-包不存在

Spring boot 无法编译命令-包不存在,spring-boot,crash,Spring Boot,Crash,我创建了非常简单的崩溃命令 @Usage("Echo") public class echo extends BaseCommand { @Command @Usage("Echo") public String main() throws IOException, InterruptedException { InvocationContextImpl ctx = (InvocationContextImpl) context; ret

我创建了非常简单的崩溃命令

@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运行此程序时,一切正常。

程序包
sth
正确吗?也许您的IDE工作区中还有另一个项目,其中包含另一个
Echo
类?不,只有一个项目如果您使用的是Spring Boot 1.4,可能是这样的:我降级到了1.3.7.RELEASE。现在可以了。我也遇到了同样的问题。通过IntelliJ运行它很好,但一旦我尝试将它作为一个JAR运行,它就失败了。我正在运行版本1.4.1,无法降级。你找到解决办法了吗,@Mateusz?