Deploy Java Web Project with Jetty


1. Jetty installation

1, jetty

 Download from the official website:
 jetty-distribution-8.1.15.v20140411

jetty-distribution-9.2.9.v20150224 .zip

Extract jetty directly to its own directory (you can move it to other places by yourself)

2, jdk configuration

Install versionjdk-8u131-macosx-x64.dmg

The default installation address is as follows: /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/< br>

Open the ~/.bash_profile file, create it if not, add the configuration at the end, so that maven can find the java directory

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Homeexport JAVA_HOM EPATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

3, maven installation configuration

Check if maven is installed 
mvn -version

3.1 Download:

apache-maven-3.0.3-bin.tar.gz

3.2 Unzip, move to your own program directory, and add to path

mv apache-maven-3.0.3 ~/Programs/ / Then add the installation path to .bash_profile-------vi ~/.bash_profile //  is your installation directory---------export PATH=$PATH:/bin // Then source the profile file and check if the installation is successful source ~/.bash_profilemvn -version

3.3 Configuration

< /p>

Configure the download dependency address.

If the settings.xml file does not exist, create one. 

Configuration settings.xml initial configuration


p>

Second, deploy the Java Web project

1. Use maven to type the project into a war package: mvn -U clean compile package

2. Copy xxx-1.0-SNAPSHOT.war in the target directory to Jetty’s decompression path, such as: /Users/xxx/Downloads/jetty-distribution-9.3.5.v20151012/webapps< /p>

3, cd to the Jetty decompression path, such as: /Users/xxx/Downloads/jetty-distribution-9.3.5.v20151012

4, execute Java -jar start.jar

p>

5. Visit http://localhost:8080/xxx-1.0-SNAPSHOT/

Leave a Comment

Your email address will not be published.