找不到文件夹位置(java.lang.IllegalStateException)

时间:2018-07-25 16:41:42

标签: java intellij-idea jetty

    public class AppServer {
    public static final String WEB_INF_LOCATION = "src/main/webapp/WEB-INF/web.xml";
    public static final String WEB_APP_LOCATION = "../ui/app";

    public static void main(String[] args) throws Exception {
        int port = Integer.valueOf(Optional.fromNullable(System.getenv("PORT")).or("8080"));
        WebServer server = new JettyWebServer(WEB_INF_LOCATION, WEB_APP_LOCATION, port, "0.0.0.0");


        System.setProperty("restx.mode", System.getProperty("restx.mode", "dev"));
        System.setProperty("restx.app.package", "orange.invoice");

        server.startAndAwait();
    }
}

错误:

线程“ main”中的异常java.lang.IllegalStateException:在/ Users / Kevin / Development / orange中找不到../ui/app 检查您的工作目录。

at restx.common.MoreFiles.checkFileExists(MoreFiles.java:103)
at restx.server.JettyWebServer.<init>(JettyWebServer.java:44)
at orange.invoice.AppServer.main(AppServer.java:20)

我具有上面的代码定义,尽管'..ui / app'位置正确,但还是出现了错误。有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="main.css"> </head> <div class="codepad-logo"> <div class="logo"></div> <div class="centered"> test </div> </html>来自项目目录,因此它正在寻找WEB_APP_LOCATION。也许您需要将其设置为/Users/Kevin/Development/ui/app

更新: 您可以将值设置为src/main/webapp/ui/app。通过添加ui/app,您可以移至项目目录的父目录。

答案 1 :(得分:-1)

它终于像这样工作了:

public static final String WEB_INF_LOCATION = "/Users/Kevin/Development/orange/server/src/main/webapp/WEB-INF/web.xml";
public static final String WEB_APP_LOCATION = "/Users/Kevin/Development/orange/ui/app";
  • 橙色是项目文件夹名称