【问题标题】:Couldn't find folder location (java.lang.IllegalStateException)找不到文件夹位置 (java.lang.IllegalStateException)
【发布时间】:2018-07-25 16:41:42
【问题描述】:
    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();
    }
}

错误:

线程“主”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' 位置是正确的,但我收到了错误。有人可以帮忙吗?

【问题讨论】:

  • 我已经尝试过删除 .idea 文件夹等操作,但仍然存在同样的问题。

标签: java intellij-idea jetty


【解决方案1】:

WEB_APP_LOCATION 来源于项目目录,所以它正在寻找/Users/Kevin/Development/ui/app。也许您需要将其设置为src/main/webapp/ui/app

更新: 您可以将值设置为 ui/app。通过添加../,您将向上移动到项目目录的父目录。

【讨论】:

  • @UniversalCodeLabs 文件夹结构是什么?您可以将位置添加到原始问题中吗?
【解决方案2】:

它终于像这样工作了:

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";
  • 橙色是项目文件夹名称

【讨论】:

  • 仅在您的机器上为真。最好不必以这种方式依赖路径。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-05
  • 2016-01-28
  • 1970-01-01
  • 1970-01-01
  • 2016-10-22
  • 2011-02-24
相关资源
最近更新 更多