官术网_书友最值得收藏!

Running the service

There are many ways to run the service.

Right-click on the project and select Run As | Maven build and configure the Run Configurations to execute the spring-boot:run target as follows:

On clicking Run, if the internet connection and configuration are fine, you will see the following console output:

[INFO] Building product 0.0.1-SNAPSHOT 
... 
[INFO] Changes detected - recompiling the module! 
[INFO] Compiling 3 source files to C:Appswkneonproducttargetclasses 
... 
 :: Spring Boot ::        (v1.4.3.RELEASE) 
 
2016-10-28 13:41:16.714  INFO 2532 --- [           main] com.mycompany.product.ProductSpringApp   : Starting ProductSpringApp on L-156025577 with PID 2532 (C:Appswkneonproducttargetclasses started by MAHAJAN in C:Appswkneonproduct) 
... 
2016-10-28 13:41:19.892  INFO 2532 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 
... 
2016-10-28 13:41:21.201  INFO 2532 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/{id}]}" onto com.mycompany.product.Product com.mycompany.product.ProductService.getProduct(int) 
2016-10-28 13:41:21.202  INFO 2532 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/productIds]}" onto java.util.List<java.lang.Integer> com.mycompany.product.ProductService.getProductIds(int) 
... 
... 
2016-10-28 13:41:21.915  INFO 2532 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http) 
2016-10-28 13:41:21.922  INFO 2532 --- [           main] com.mycompany.product.ProductSpringApp   : Started ProductSpringApp in 6.203 seconds (JVM running for 14.199) 

Note the stages of the Maven execution:

  1. First, the Maven task compiles all the Java files. We have three simple Java classes as of now.
  2. The next step runs it as an application, where a Tomcat instance starts.
  3. Note the mapping of the URLs /product/ and /productIds to the Bean methods.
  4. Tomcat listens on port 8080 for service requests.

You can also run the service by just right-clicking the class that has the main method (ProductSpringApp) in Package Explorer and then selecting Run As | Java Application.

主站蜘蛛池模板: 罗定市| 台东县| 新昌县| 永年县| 蛟河市| 锡林郭勒盟| 嘉峪关市| 鄂伦春自治旗| 石台县| 沅江市| 通城县| 岳阳市| 卫辉市| 延长县| 耒阳市| 来凤县| 盘山县| 云林县| 高安市| 勃利县| 岐山县| 瑞安市| 南郑县| 洪泽县| 隆安县| 库尔勒市| 玉树县| 黎川县| 乌兰察布市| 托里县| 麻城市| 比如县| 女性| 东港市| 阿城市| 望江县| 咸宁市| 商丘市| 社旗县| 东兴市| 英山县|