在Heroku平台上部署maven webapp(java web)項目

來源:互聯網
上載者:User

標籤:heroku

目前,想要在Heroku上面部署java web項目,該項目就必須用maven管理

一:建立maven webapp項目

編輯pom.xml檔案,加入如下配置

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>com.lala</groupId>    <artifactId>tangshiyi</artifactId>    <packaging>war</packaging>    <version>1.0.0</version>    <name>tangshiyi Maven Webapp</name>    <url>http://maven.apache.org</url>    <dependencies>        <dependency>            <groupId>junit</groupId>            <artifactId>junit</artifactId>            <version>4.11</version>            <scope>test</scope>        </dependency>        <dependency>            <groupId>javax.servlet</groupId>            <artifactId>javax.servlet-api</artifactId>            <version>3.0.1</version>            <scope>provided</scope>        </dependency>        <dependency>            <groupId>javax.servlet</groupId>            <artifactId>jsp-api</artifactId>            <version>2.0</version>            <scope>provided</scope>        </dependency>    </dependencies>    <build>        <finalName>jeecms</finalName>        <plugins>            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-compiler-plugin</artifactId>                <version>3.3</version>                <configuration>                    <source>1.8</source>                    <target>1.8</target>                    <verbose>true</verbose>                </configuration>            </plugin>            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-dependency-plugin</artifactId>                <version>2.10</version>                <executions>                    <execution>                        <phase>package</phase>                        <goals>                            <goal>copy</goal>                        </goals>                        <configuration>                            <artifactItems>                                <artifactItem>                                    <groupId>org.eclipse.jetty</groupId>                                    <artifactId>jetty-runner</artifactId>                                    <version>9.2.11.v20150529</version>                                    <destFileName>jetty-runner.jar</destFileName>                                </artifactItem>                            </artifactItems>                        </configuration>                    </execution>                </executions>            </plugin>            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-war-plugin</artifactId>                <version>2.6</version>                <configuration>                    <warName>tangshiyi</warName>                </configuration>            </plugin>        </plugins>    </build></project>


二:編寫運行war包的命令

在項目的根目錄下建立

Procfile 檔案(注意檔案名稱要一模一樣)


web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/tangshiyi.war


注意這裡的war包的名字需要和上面pom.xml裡面配置的要一樣


三:在github上面建立tangshiyi項目,並剛才建立的項目push上去

四:在heroku上面建立一個應用並關聯github上面剛剛建立的項目,部署即可

五:訪問

https://${xxxx}.herokuapp.com/

${xxxx}為第四步建立應用的名字


---------------------------------------------------

maven技術交流群:379165311,歡迎大家加入


在Heroku平台上部署maven webapp(java web)項目

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.