Heroku Deploying Java Web Projects

Source: Internet
Author: User
Tags heroku toolbelt

Pre-preparation
    • Download Heroku Toolbelt Tools
    • Heroku login command, set Heroku's mailbox and password
    • Official documentation for deploying Java applications using Jetty-runner
    • Getting Started with Spring MVC Hibernate on Heroku (https://devcenter.heroku.com/articles/ Getting-started-with-spring-mvc-hibernate)
    • Create a Java Web application Using Embedded Tomcat (https://devcenter.heroku.com/articles/ CREATE-A-JAVA-WEB-APPLICATION-USING-EMBEDDED-TOMCAT)
Create a MVN project
//创建webapp类型的mvn项目-DarchetypeArtifactId=maven-archetype-webapp

If you created with eclipse, you can view: Create a MVN project in eclipse

Add the Jetty-runner server to the Pom.xml file

<build>...<plugins>...<plugin>            <groupId>Org.apache.maven.plugins</groupId>            <artifactid>Maven-dependency-plugin</artifactid>            <version>2.3</version>            <executions>                <execution>                    <phase>Package</phase>                    <goals><goal>Copy</goal></goals>                    <configuration>                        <artifactitems>                            <artifactitem>                                <groupId>Org.mortbay.jetty</groupId>                                <artifactid>Jetty-runner</artifactid>                                <version>7.5.4.v20111024</version>                                <destfilename>Jetty-runner.jar</destfilename>                            </artifactitem>                        </artifactitems>                    </configuration>                </Execution>            </executions>        </plugin>    </plugins></Build>

Execute the MVN package command to download the Jar pack and package it to target, and if not packaged, an error occurs when running the server locally

Create a Procfile file

For Unix-like systems, add the following line:
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
If you are a Windows system:
web: java -jar target/dependency/jetty-runner.jar --port $PORT target/*.war

    • $ JAVA_OPTSAnd: cannot be used under Windows, so to replace, *.war can use Applicationname.war
Create a System.properties file

Add the following line:
java.runtime.version=1.7
Heroku default is 1.6

Add Git version control
commit -m"ready to deploy"
Create a. gitignore file

In the file, add:
Target

Deploying Apps to Heroku
create [name]   //创建heroku应用,name为可选git push heroku master heroku ps:scale web=1//设置dynos为一个,heroku只提供一个免费的dynoopen //打开页面foreman start web -f Procfile.windows //在本地运行应用,http://localhost:5000,若为linux系统则可以省略-f 。。。

Heroku Deploying Java Web Projects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.