Deploy the maven webapp (java web) project on the Heroku platform, herokumaven
To deploy a java web project on Heroku, you must use maven to manage the project.
I. Create a maven webapp Project
Edit the pom. xml file and add the following Configuration:
<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>
Ii. Compile the command to run the war package
Create in the root directory of the project
Procfile file (note that the file name must be the same)
Web: java $ JAVA_OPTS-jar target/dependency/jetty-runner.jar -- port $ PORT target/tangshiyi. war
Note that the war package name must be the same as the one configured in pom. xml above.
3. Create the tangshiyi project on github and push the project just created
4. Create an application on heroku and associate it with the newly created Project on github. Just deploy the application.
V. Access
Https: // $ {xxxx} .herokuapp.com/
$ {Xxxx} is the name of the application created in step 4.
---------------------------------------------------
Maven technical exchange group: 379165311. Welcome to join