-
get back to your working directory.
-
add these snipets into your pom.xml
<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.8.v20160314</version> <destFileName>jetty-runner.jar</destFileName> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.8.v20160314</version> </plugin>
<dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-servlet</artifactId> <version>9.3.8.v20160314</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> <version>9.3.8.v20160314</version> </dependency>
-
mvn package and run as
java -jar target/dependency/jetty-runner.jar target/*.war
-
if successful in local, commit github
-
git commit
-
git push origin deploytogoogle
- go to https://cloud.google.com/
- click "TRY IT FREE"
- create account
Following instructions are same as this page
- open GCP console https://console.cloud.google.com
- click [▽] in top of bar
- click [+]
- input project name (ex. interview-gami)
- click [create]
- wait a second (would take a few seconds)
- select your project in top of bar
- select Menu (〓) , then Billing & alerts
- Create BUDGET
- set ammount of money like this
- Select Menu (〓) , then click Compute Engine
- wait a second
- select VM instances
- Create an instance
- click [create]
- wait a second
- click your instance in "VM instances" view to goto "VM instance detail"
- Remember external IP
- open terminal
ssh YOUR_EXTERNAL IP
- type following commands
sudo apt-get update
sudo apt install -y openjdk-8-jdk maven
git clone https://github.com/YOUR_NAME/YOUR_REPOSITORY
cd YOUR_REPOSITORY
git checkout deploytogoogle
mvn package
sudo java -jar target/dependency/jetty-runner.jar -—port 80 target/*.war
- VM instances -> your instance -> Click "External IP (10…)"
- open http://{PASTE EXTERNAL_IP}/interview/Java
- create an account https://www.noip.com/sign-up
- log in https://my.noip.com/#!/
- add quick dns
- input myhost
- add hostname
- click Dynamic DNS [Free] in a left pane
- click your created dns
- input your external IP of the instance onto IPv4 Address
- open YOUR_DDNS.ddns.com/interview/Java
- it can take a few minutes to update
- Go to VM instances and select your instance then click [DELETE]
- click "Fork" in https://github.com/iwag/java-jersey-restful-server-client-sample
- open terminal
- git clone git@github.com:!!!YOUR_NAME!!!/java-jersey-restful-server-client-sample.git
- install maven https://maven.apache.org/install.html
- https://brew.sh/ can be helpful to install
brew install maven
if you have brew
- cd java-jersey-restful-server-client-sample
- mvn package
- java -jar target/dependency/jetty-runner.jar target/*.war
- open http://localhost:8080/interview/Java
- I don't use tomcat for several reasons like confusing setup. I think jetty is much easier way to run servlet container