在Heroku平台上部署mavenwebapp(javaweb)项目


目前,想要在Heroku上面部署java web项目,该项目就必须用maven管理

一:新建maven webapp项目

编辑pom.xml文件,加入如下配置


    4.0.0
    com.lala
    tangshiyi
    war
    1.0.0

    tangshiyi Maven Webapp
    http://maven.apache.org

    
        
            junit
            junit
            4.11
            test
        
        
            javax.servlet
            javax.servlet-api
            3.0.1
            provided
        
        
            javax.servlet
            jsp-api
            2.0
            provided
        
    

    
        jeecms
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.3
                
                    1.8
                    1.8
                    true
                
            
            
                org.apache.maven.plugins
                maven-dependency-plugin
                2.10
                
                    
                        package
                        
                            copy
                        
                        
                            
                                
                                    org.eclipse.jetty
                                    jetty-runner
                                    9.2.11.v20150529
                                    jetty-runner.jar
                                
                            
                        
                    
                
            
            
                org.apache.maven.plugins
                maven-war-plugin
                2.6
                
                    tangshiyi

二:编写运行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}为第四步创建应用的名字

相关内容