
上QQ阅读APP看书,第一时间看更新
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:
- First, the Maven task compiles all the Java files. We have three simple Java classes as of now.
- The next step runs it as an application, where a Tomcat instance starts.
- Note the mapping of the URLs /product/ and /productIds to the Bean methods.
- 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.