import javax.inject.Inject; public class OrderService { @Inject private CustomerService customerService; public void placeOrder(String customerId, String productId) { customerService.processOrder(customerId, productId); } } public class CustomerService { public void processOrder(String customerId, String productId) { System.out.println("Processing order for customer: " + customerId + ", product: " + productId); } } public class Main { public static void main(String[] args) { Weld weld = new Weld(); WeldContainer container = weld.initialize(); OrderService orderService = container.select(OrderService.class).get(); orderService.placeOrder("123456", "abc123"); weld.shutdown(); } }


上一篇:
下一篇:
切换中文