Configure the DB as described in section Config Data Source under OrderController.
Run the OpenRewrite recipes, either via the VSCode UI (like we was done for the common library) or by going to the command line window and doing:
cd C:\vFunctionLab\oms-services\order-controller
mvn rewrite:run
The compilation will fail an import statement (import javax.transaction.Transactional;) in com.oms.service.OrderService.java. Open the file OrderService.java (you can use Ctrl+P in VSCode) and modify the import to:
import jakarta.transaction.Transactional;
Now re-run mvn rewrite:run
and it should succeed.
Edit the class com.oms.ordercontroller.OrderControllerApp.java
Add the annotations @EntityScan({ "com.oms.entity" })
and @ComponentScan("com.oms")
(ensure the double quotes are copied correctly - see above note)
Add the requirement import statements (import org.springframework.boot.autoconfigure.domain.EntityScan;
and import org.springframework.context.annotation.ComponentScan;
)
The file should be similar to the below (the added lines are marked //added):
package com.oms.ordercontroller;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan; // added
import org.springframework.context.annotation.ComponentScan; // added
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@ImportResource({"META-INF/rr/**/*.xml"})
@ComponentScan("com.oms") // added
@EntityScan("com.oms.entity") // added
public class OrderControllerApp {
public static void main(String[] args)
{
SpringApplication.run(OrderControllerApp.class, args);
}
}
Compile the service by doing Maven clean and Maven install
Run the service as a Spring Boot App, either from the Spring Boot Dashboard in VSCode (screenshot below)
or by doing in the command window:
cd c:\vFunctionLab\oms-services\order-controller
java -jar .\target\OrderController-1.0-SNAPSHOT.jar
Click on “Thunder Client” icon on the left panel to switch to the Client Thunder view in VSCpde
Click on Collections, then the menu item import
Import the file C:\vFunctionLab\oms-tutorial\oms-services\OMS Services.postman_collection.json
Select under Orders the POST message “Create Order”, switch to Body and change the customerOrderId to 1.
Hit send - you should get an OK response
Try the other API calls under Orders
Commit the modified files (no need to commit oms-log.txt and launch.json)