vFunction Logo

Order Controller

  1. Configure the DB as described in section Config Data Source under OrderController.

  2. 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.

  3. Edit the class com.oms.ordercontroller.OrderControllerApp.java

  4. Add the annotations @EntityScan({ "com.oms.entity" }) and @ComponentScan("com.oms")(ensure the double quotes are copied correctly - see above note)

  5. Add the requirement import statements (import org.springframework.boot.autoconfigure.domain.EntityScan; and import org.springframework.context.annotation.ComponentScan;)

  6. 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);
        }
    }
  7. Compile the service by doing Maven clean and Maven install

  8. Run the service as a Spring Boot App, either from the Spring Boot Dashboard in VSCode (screenshot below) Run-SBApp

    or by doing in the command window:

    cd c:\vFunctionLab\oms-services\order-controller
    java -jar .\target\OrderController-1.0-SNAPSHOT.jar
  9. Copy the file orders-requests.http from the original git repository to the service folder

    copy c:\vFunctionLab\oms-tutorial\oms-services\orders-requests.http c:\vFunctionLab\oms-services\order-controller 
  10. In VSCode, open the file orders-requests.http

  11. Run the APIs by clicking Send Request above the various REST APIs calls and review the responses (first create orders and then get an order)

  12. Commit the modified files (no need to commit oms-log.txt and launch.json)

vFunction Logo