public interface GreetingService { void greet(String name); } public class GreetingServiceImpl implements GreetingService { public void greet(String name) { System.out.println("Hello, " + name + "!"); } } serviceImplementation=com.example.GreetingServiceImpl public class MyApp { public static void main(String[] args) { FrameworkFactory factory = new FrameworkFactory(); Framework framework = factory.newFramework(null); try { framework.start(); ServiceRegistry serviceRegistry = framework.getServiceRegistry(); Configuration configuration = serviceRegistry.createConfiguration("greeting-service.config"); configuration.update(); GreetingService greetingService = serviceRegistry.getService(GreetingService.class); greetingService.greet("Alice"); framework.stop(); } catch (Exception e) { e.printStackTrace(); } } }


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