public static void main(String[] args) throws Exception {
    // 设定Spring的profile
    System.setProperty("spring.profiles.active", "development");

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

    try {
      server.start();

      System.out.println("Server running at " + BASE_URL);
      System.out.println("Hit Enter to reload the application");

      // 等待用户输入回车重载应用.
      while (true) {
        char c = (char) System.in.read();
        if (c == '\n') {
          JettyFactory.reloadContext(server);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }
Example #2
0
  public static void main(String[] args) throws Exception {
    // 设定Spring的profile
    Profiles.setProfileAsSystemProperty(Profiles.DEVELOPMENT);

    // 启动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);
    }
  }
  /** 启动Jetty服务器, 仅启动一次. */
  protected static void startJettyOnce() throws Exception {
    if (jettyServer == null) {
      // 设定Spring的profile
      Profiles.setProfileAsSystemProperty(Profiles.FUNCTIONAL_TEST);

      jettyServer =
          JettyFactory.createServerInSource(new URL(baseUrl).getPort(), SportStartServer.CONTEXT);
      JettyFactory.setTldJarNames(jettyServer, SportStartServer.TLD_JAR_NAMES);
      jettyServer.start();

      logger.info("Jetty Server started at {}", baseUrl);
    }
  }
Example #4
0
  @Test
  public void createServer() {
    Server server = JettyFactory.createServerInSource(1978, "/test");

    assertEquals(1978, server.getConnectors()[0].getPort());
    assertEquals("/test", ((WebAppContext) server.getHandler()).getContextPath());
    assertEquals("src/main/webapp", ((WebAppContext) server.getHandler()).getWar());
  }