Example #1
0
  public static void main(String[] args) throws Exception {
    // 设定Spring的profile
    Profiles.setProfileAsSystemProperty(Profiles.DEV);

    // 启动Jetty
    Server server = JettyFactory.createServerInSource(PORT, CONTEXT);
    JettyFactory.setTldJarNames(server, TLD_JAR_NAMES);

    try {
      server.start();

      System.out.println("[INFO] Server running at http://localhost:" + PORT + CONTEXT);
      System.out.println("[HINT] Hit Enter to reload the application quickly");

      // 等待用户输入回车重载应用.
      while (true) {
        char c = (char) System.in.read();
        if (c == '\n') {
          JettyFactory.reloadContext(server);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }