使用sun httpserver部署heroku java web服务器

使用sun httpserver部署heroku java web服务器,java,heroku,webserver,Java,Heroku,Webserver,我用Java sun httpserver库在我的计算机上构建了一个小型演示服务器 现在,我想公开并将其部署到heroku 简单地说,这是我的Main.java类(如下) 它是作为一个Maven项目构建的 我将herkou与我的maven项目(代码位于github上)连接起来,maven的编译和运行阶段让我获得了“构建成功” 但是,当我在本地环境()中尝试访问我的服务器时,当我输入这个url(我的herkou站点)时,我现在收到一条消息:“页面无法加载” herkou是否在maven项目中自动运

我用Java sun httpserver库在我的计算机上构建了一个小型演示服务器

现在,我想公开并将其部署到heroku

简单地说,这是我的Main.java类(如下)

它是作为一个Maven项目构建的

我将herkou与我的maven项目(代码位于github上)连接起来,maven的编译和运行阶段让我获得了“构建成功”

但是,当我在本地环境()中尝试访问我的服务器时,当我输入这个url(我的herkou站点)时,我现在收到一条消息:“页面无法加载”

herkou是否在maven项目中自动运行我的main方法(我需要这样做,因为我的服务器从我的main方法启动)

如果是这样,还有什么问题

谢谢

public class Main {
    static MySQLQueryExecutor mySQLQueryExecutor=MySQLQueryExecutor.getInstance();
    public static void main(String[] args) throws Exception {
        HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
        server.createContext("/test", new MyHandler());

        server.setExecutor(null);
        server.start();
        System.out.println(server.getAddress());
    }



    static class MyHandler implements HttpHandler {

        public void handle(HttpExchange t) throws IOException {
            String response = "This is Get response";
            t.sendResponseHeaders(200, response.length());
            OutputStream os = t.getResponseBody();
            os.write(response.getBytes());
            os.close();
        }
    }


}
建筑日志:

-----> Java app detected
-----> Installing OpenJDK 1.8... done
-----> Installing Maven 3.3.9... done
-----> Executing: mvn -DskipTests clean dependency:list install
       [INFO] Scanning for projects...
       [INFO]                                                                         
       [INFO] ------------------------------------------------------------------------
       [INFO] Building my_demo 1.0-SNAPSHOT
       [INFO] ------------------------------------------------------------------------
       [INFO] 
       [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my_demo ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ my_demo ---
       [INFO] 
       [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my_demo ---
       [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
       [INFO] skip non existing resourceDirectory /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/src/main/resources
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my_demo ---
       [INFO] No sources to compile
       [INFO] 
       [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my_demo ---
       [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
       [INFO] skip non existing resourceDirectory /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/src/test/resources
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ my_demo ---
       [INFO] No sources to compile
       [INFO] 
       [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my_demo ---
       [INFO] Tests are skipped.
       [INFO] 
       [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my_demo ---
       [WARNING] JAR will be empty - no content was marked for inclusion!
       [INFO] Building jar: /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/target/my_demo-1.0-SNAPSHOT.jar
       [INFO] 
       [INFO] --- maven-install-plugin:2.4:install (default-install) @ my_demo ---
       [INFO] Installing /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/target/my_demo-1.0-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/yotam/my_demo/1.0-SNAPSHOT/my_demo-1.0-SNAPSHOT.jar
       [INFO] Installing /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/pom.xml to /app/tmp/cache/.m2/repository/yotam/my_demo/1.0-SNAPSHOT/my_demo-1.0-SNAPSHOT.pom
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD SUCCESS
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time: 2.365 s
       [INFO] Finished at: 2017-05-08T16:28:54+00:00
       [INFO] Final Memory: 16M/167M
       [INFO] ------------------------------------------------------------------------
-----> Discovering process types
       Procfile declares types -> (none)
-----> Compressing...
       Done: 48M
-----> Launching...
       Released v7
       https://shaffa.herokuapp.com/ deployed to Heroku
应用程序日志

2017-05-08T14:17:52.452910+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=shaffa.herokuapp.com request_id=5f365605-2f15-45d7-a043-5aea122ab4b8 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https
2017-05-08T16:28:47.000000+00:00 app[api]: Build started by user yz@gmail.com
2017-05-08T16:28:49.000000+00:00 app[api]: Build started by user yz@gmail.com
2017-05-08T16:29:00.835249+00:00 app[api]: Deploy dd12826 by user yz@gmail.com
2017-05-08T16:29:00.835249+00:00 app[api]: Release v7 created by user yz@gmail.com
2017-05-08T16:28:47.000000+00:00 app[api]: Build succeeded
2017-05-08T16:29:03.635910+00:00 app[api]: Deploy dd12826 by user yz@gmail.com
2017-05-08T16:28:49.000000+00:00 app[api]: Build succeeded
2017-05-08T16:29:03.635910+00:00 app[api]: Release v8 created by user yz@gmail.com
2017-05-08T16:29:08.055046+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=shaffa.herokuapp.com request_id=c06affca-0979-4e7c-aafe-69e5296a33c0 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https
2017-05-08T16:29:08.706745+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=shaffa.herokuapp.com request_id=f11fe11a-a99a-4f19-bbff-34b0a84fa1f3 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https

您需要在仪表板的“资源”选项卡中将应用程序扩展到至少一个dyno

部署后运行heroku logs-t,并在此处发布输出。另外,您的
Procfile
包含哪些内容?添加到原始msgalso中,因此我没有Procfile,也没有dynoI。我使用的不是CLI,而是仪表板。如何创建procfile+dyno?它是强制性的吗?