heroku部署java web項目,heroku部署javaweb

來源:互聯網
上載者:User

heroku部署java web項目,heroku部署javaweb

一、開發

在本地eclipse建立maven web項目(此時可以當成正常的javaweb項目開發即可。注意添加servlet依賴,此時不用添加jetty依賴)

 

二、部署前準備

1、首先在pom.xml中配置jetty-runner,如下:

<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.eclipse.jetty</groupId>                <artifactId>jetty-runner</artifactId>                <version>9.3.3.v20150827</version>                <destFileName>jetty-runner.jar</destFileName>              </artifactItem>            </artifactItems>          </configuration>        </execution>       </executions>    </plugin>  </plugins></build>

2、然後先在本地測試一下:

控制台鍵入命令

mvn package

java -jar target/dependency/jetty-runner.jar target/*.war

此時訪問localhost:8080應該能訪問項目

3、建立system.properties檔案,在檔案中輸入java.runtime.version=1.8(You can specify 1.6, 1.7, or 1.8 (1.8 is in beta) for Java 6, 7, or 8 (with lambdas), respectively.)

三、部署

部署前先從heroku上下載

1、首先git提交到本地倉庫:
git add .

git commit -m "inti heroku app"

2、建立heroku app

控制台輸入:

heroku create

3、然後提交到遠程倉庫heroku

git push heroku master

 

現在可以運行heroku open訪問應用了!

 

四、重新命名

在heroku網站上重新命名app後在控制台再輸入heroku命令會提示App Not Found,解決辦法:

git remote rm heroku

heroku git:remote -a newname

具體可參考Stackoverflow上:http://stackoverflow.com/questions/7615807/renamed-heroku-app-from-website-now-its-not-found

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.