- Cloud-Native Applications in Java
- Ajay Mahajan Munish Kumar Gupta Shyam Sundar
- 267字
- 2021-06-24 19:07:16
Creating a deployable
We are not going to run our service on Eclipse. We would like to deploy it on a server. There are two options for doing this:
- Create a WAR and deploy it in Tomcat or any other web container. This is the traditional method.
- Create a JAR with the runtime (Tomcat) included so that you just need Java to execute the service.
In cloud application development, the second option, also called fat JAR or uber JAR, is becoming popular for the following reasons:
- The deployable is self-contained with all the dependencies it needs. This reduces the chances of environment mismatch as the deployable unit is deployed to Dev, Test, UAT, and Production. If it works in development, there is a good chance it will work across all the other environments.
- The host, server, or container where the service is deployed need not have a preinstalled application server or servlet engine. Just a basic JRE is good enough.
Let's look at the steps to create a JAR file and run it.
Include the following dependencies of the POM file:
<build><plugins><plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin></plugins></build>
Now, run it by right-clicking the project in the explorer and choosing Run As | Maven Install.
You will see product-0.0.1-SNAPSHOT.jar in the target directory of the project folder structure.
Navigate to the product folder so that you see the target directory in the command line and then run the JAR through a Java command, as shown in the following screenshot:

You will see Tomcat listening to the port at the end of the startup. Test it through the browser again. Milestone achieved.
- 圖像目標(biāo)跟蹤技術(shù)
- 中國(guó)自動(dòng)化技術(shù)發(fā)展報(bào)告
- 通信網(wǎng)絡(luò)智能管道架構(gòu)與技術(shù)實(shí)現(xiàn)
- 電子工程師自學(xué)速成:設(shè)計(jì)篇(第2版)
- Identity with Windows Server 2016:Microsoft 70-742 MCSA Exam Guide
- 5G大規(guī)模天線增強(qiáng)技術(shù)
- 區(qū)域智能電網(wǎng)的規(guī)劃方法
- 光波分復(fù)用系統(tǒng)與維護(hù)
- 動(dòng)手指,知天下:老年人學(xué)用智能手機(jī)
- 妙用微信微博就讀它
- 電子組裝先進(jìn)工藝
- 電子元器件檢測(cè)與應(yīng)用
- 虛擬視點(diǎn)圖像/視頻質(zhì)量度量及應(yīng)用
- 三菱FX系列PLC數(shù)據(jù)通信及測(cè)控應(yīng)用
- 新一代移動(dòng)融合網(wǎng)絡(luò)理論與技術(shù)